<?php include "conexao.php";   ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>aguarde...</title> <script type="text/javascript"> function loginSuccessfully(){ setTimeout("window.location = 'page.php'",3000); } function loginFailed(){ setTimeout("window.location = 'index.php'",100);	 } </script> </head> <body> <?php $user = $_POST['username'];  $pass = $_POST['pass'];   $sql = mysql_query("SELECT * FROM user_table WHERE usuario='{$user}' and senha='{$pass}' ")or die (mysql_error()); $row = mysql_num_rows($sql); if($row > 0 ){ 	session_start(); 	$_SESSION['username']	= $user; 	$_SESSION['senha']	 	= $pass; 	$_SESSION['id']         = $row['id']; 	//$_SESSION['usercolegio']= $row['colegio']; 	echo "Autenticando..."; 	echo "<script>loginSuccessfully()</script>"; }  else{ 	echo "<script>loginFailed()</script>";	 	echo "<script>alert('Usuário ou senha incorretos')</script>"; } ?> </body> </html>