o banco de dados mysql_select_db($database_data); #Fazer a pesquisa na tabela $sql_Login ="SELECT username, password FROM users_db WHERE username='".$loginUsuario."' AND password='".$LoginSenha."'"; $rs_login = mysql_query($sql_Login, $cnn_data) or die(mysql_error()); $rs_Login_Linhas = mysql_num_rows($rs_login); #Validar o login if($rs_Login_Linhas){ #Opcional Variavel de Grupo e Nome do Usuario $loginGrupo = ""; $loginNome = ""; #Declarar as variaveis $_SESSION['MM_Login'] = true; $_SESSION['MM_Username'] = $loginUsuario; $_SESSION['MM_UserGroup'] = $loginGrupo; #Redirecionar a pagina header("Location: ". $Redirecionar_Confirmado); } else { #Declarar as variaveis $_SESSION['MM_Login'] = false; $_SESSION['MM_frmLogin'] = "index.php"; $_SESSION['MM_Erro'] = "Erro ao realizar o login verifique o usu&aacute;rio e senha..."; #Redirecionar a pagina header("Location: ". $Redirecionar_NaoComfirmado); } }?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Login</title></head><body><form name="form1" method="post" action="index.php"> <table width="200" border="0" cellpadding="2" cellspacing="0"> <tr> <td align="left"><b>Usuario:</b></td> <td align="left"><input type="text" name="txtuser" id="txtuser"></td> </tr> <tr> <td align="left"><b>Senha:</b></td> <td align="left"><input type="password" name="txtpwd" id="txtpwd"></td> </tr> <tr> <td align="left"><b></b></td> <td align="left"><input type="submit" name="bnt" id="bnt" value="Entrar"></td> </tr> </table></form></body></html>3o PassoCriar a pagina "error.php"<?php/* Informacoes de Codigo Desenvolvido por Eduardo Vieira Data:16/06/2014 Email:eduardocobain@bol.com.br*/ if (!isset($_SESSION)) { session_start(); } if($_SESSION['MM_Login']=="" || $_SESSION['MM_Login']==NULL || $_SESSION['MM_Login']==false){ #Declarar as variaveis $_SESSION['MM_Login'] = false; $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); $Redirecionar = $_SESSION['MM_frmLogin']; }?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Error</title></head><body><p><?php echo $_SESSION['MM_Erro'];?></p><a href="<?php echo $Redirecionar; ?>">Voltar</a></body></html>4o PassoCriar a pagina do Painel ou perfil "home.php"<?php/* Informacoes de Codigo Desenvolvido por Eduardo Vieira Data:16/06/2014 Email:eduardocobain@bol.com.br*/if (!isset($_SESSION)) { session_start();}if($_SESSION['MM_Login']=="" || $_SESSION['MM_Login']==NULL || $_SESSION['MM_Login']==false){ #Declarar as variaveis $_SESSION['MM_Login'] = false; $_SESSION['MM_Erro']= "Usuario nao esta Logado.."; #Caso o tenha feito o login entao enviar para a pagina de erro. $Redirecionar_NaoComfirmado = "error.php"; header("Location: ". $Redirecionar_NaoComfirmado);}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Home</title></head><body><p>Pagina home</p></body></html>Se voce tentar acessar a pagina home direto sem ter feito o login ele redireciona para a pagina error.phpBom e isso ai espero que tenha ajudado... ate mais