Pegar Usuário da Session
Pessoal,Estou tendo criar um sistema que tem um login e senha. Veja o código:
> // obtém os valores digitados$login = $_POST["login"];$senha = $_POST["senha"];// Conexão com o banco de badosinclude("conexao.php");$result = mysql_query("select * from professores where login = '$login'");$recset=mysql_num_rows($result);if($recset==0) // testa se a consulta retornou algum registro{echo "<html><body>";echo "<hr>";echo "<p align=\"center\">Usuários não encontrado !</p>";echo "<p align=\"center\"><a href=\"index.php\">Voltar</a></p>";echo "<hr>";echo "</body></html>";}else{if ($senha !=mysql_result($result,0,"senha")) // confere senha{echo "<html><body>";echo "<hr>";echo "<p align=\"center\">A senha está incorreta !</p>";echo "<p align=\"center\"><a href=\"index.php\">Voltar</a></p>";echo "<hr>";echo "</body></html>";}else // usuário e senha corretos. vamos criar os cookies{ session_start(); $_SESSION["cod_professor"] = $recset["codigo"]; $_SESSION["login"] = $recset["login"]; header("Location: sgp.php"); exit; mysql_close($conexao);}}?>
Mas quero exibir os dados do professor logando. Veja o código:
> <?phpsession_start();$login = $_SESSION["login"]; #Arquivo de funções ************************************* include("conexao.php");#********************************************************$sql ="select * from professores WHERE login ='$login'"; $resultado = mysql_query($sql); $linha = mysql_fetch_array($resultado);$nome = $linha["nome"];$data_nascimento = $linha["data_nascimento"];$complemento = $linha["complemento"];$bairro = $linha["bairro"];$cidade = $linha["cidade"];$estado = $linha["estado"];$cidade = $linha["cidade"];$telefone = $linha["telefone"];$celular = $linha["celular"];$senha = $linha["senha"];?><html><head><title>SGP - Professores</title><link href="estilo.css" rel="stylesheet" type="text/css"></head><body bgcolor="#FFFFFF"><form name="form1" method="post" action="/escolas/professores/dados.php"> <table width="300" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#EBE9ED"> <tr> <td width="110">Professor:</td> <td width="190"><input name="nome" type="text" value="<?=$linha["nome"]?>" size="35"></td> </tr> <tr> <td width="110">Data Nascemento:</td> <td width="190"><input name="data_nascimento" type="text" value="<?=$linha["data_nascimento"]?>" size="35"></td> </tr> <tr> <td width="110">Endereço:</td> <td width="190"><input name="endereco" type="text" value="<?=$linha["endereco"]?>" size="35"></td> </tr> <tr> <td width="110">Complemento:</td> <td width="190"><input name="complemento" type="text" value="<?=$linha["complemento"]?>" size="35"></td> </tr> <tr> <td width="110">Bairro:</td> <td width="190"><input name="bairro" type="text" value="<?=$linha["bairro"]?>" size="35"></td> </tr> <tr> <td width="110">Cidade:</td> <td width="190"><input name="cidade" type="text" value="<?=$linha["cidade"]?>" size="35"></td> </tr> <tr> <td width="110">Estado:</td> <td width="190"><input name="estado" type="text" value="<?=$linha["estado"]?>" size="35"></td> </tr> <tr> <td width="110">Telefone:</td> <td width="190"><input name="telefone" type="text" value="<?=$linha["telefone"]?>" size="35"></td> </tr> <tr> <td width="110">Celular:</td> <td width="190"><input name="celular" type="text" value="<?=$linha["celular"]?>" size="35"></td> </tr> <tr> <td width="110">Senha:</td> <td width="190"><input name="senha" type="password" value="<?=$linha["senha"]?>" size="35"></td> </tr> <tr> <td width="110">Confirma Senha:</td> <td width="190"><input name="confirma" type="password" size="35"></td> </tr> <tr align="right"> <td colspan="2"><input type="hidden" name="id" value="7"> <input type="hidden" name="Alterar" value="ok"> <input type="submit" name="Submit" value="Alterar"></td> </tr></table></form></body></html>
Portanto, clico no link o formulário não exibe nada.Alguem pode me ajudar nesse código.Um abraço.Alissong
Discussão (12)
Carregando comentários...