logando.php
<?php $host = "localhost"; $username = "teste"; $password = "teste"; $bd = "teste"; if (!isset($user)) { header("Location: logar.php?erro=O campo Username está vazio!."); exit; } elseif (!isset($senha)) { header("Location: logar.php?erro=O campo Senha está vazio!"); exit; } else { $conexao = @mysql_connect($host, $username, $password); $banco = @mysql_select_db($bd, $conexao); $sql = @mysql_query("SELECT * FROM teste WHERE user='$user' and senha='$senha'"); $total = mysql_num_rows($sql); if ($total == 1) { session_start(); session_register("$user","$senha"); header("Location: restrito.php"); exit; } else { header("Location: index.php"); } } mysql_close($conexao) ?>
restrito.php
<?php if(!(session_is_registered("user") AND session_is_registered("senha"))){ header("Location: logar.php"); exit; }else{ ?> <html> <head> <title>Usuário Cadastrado</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <font color="#000000"> <h2>ÁREA RESTRITA! <BR> USUÁRIO CADASTRADO!<BR> SEJA BEM VINDO! </h2></font> </body> </html> <?php } ?>
Ajudem aew, é urgente!
Forte Abraço,
Allan Bruno