nuboza 0 Denunciar post Postado Março 17, 2005 Baa a tarde a todos estive olhando um artigo (nº 87 em PHP ) do site imasters sobre autenticação usando sessoes em PHP peguei ate os modelos pra testar aqui so que estou tendo um problema na hora em que a index.php chama a pagina autentica.php o problema é esse: Notice: Use of undefined constant txtUser - assumed 'txtUser' in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 6 Notice: Use of undefined constant txtSenha - assumed 'txtSenha' in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 7 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\program files\easyphp1-8\www\teste\autentica\autentica.php:6) in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 27 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp1-8\www\teste\autentica\autentica.php:6) in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 27 Notice: Use of undefined constant id - assumed 'id' in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 30 Notice: Use of undefined constant nome - assumed 'nome' in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 31 Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\teste\autentica\autentica.php:6) in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 34 Não sei como arrumar esse problema o engracado, é que isso acontece quando digito o login e senha correta se por acaso eu digitar um login e senha que nao existe aparece somente isto: Notice: Use of undefined constant txtUser - assumed 'txtUser' in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 6 Notice: Use of undefined constant txtSenha - assumed 'txtSenha' in c:\program files\easyphp1-8\www\teste\autentica\autentica.php on line 7 Usuário/Senha inválidos O que eu faço? Eu acho que deve estar ocorrendo um problema na hora da coleta de dados da 'txtUser' e 'txtSenha' abaixo vou mostrar o codigo da index.php e da autentica.php assim quem sabe voces podem me ajudar com alguma observação! index.php <h2>87º artigo PHP - iMasters</h2><form name="frmAutentica" method="post" action="autentica.php"> <table border="0" cellpading="0" cellspacing="0" width="50%"> <tr> <td width="10%">Usuário:</td> <td width="40%"><input type="text" name="txtUser" size="25"></td> </tr> <tr> <td width="10%">Senha:</td> <td width="40%"><input type="password" name="txtSenha" size="10"></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" name="btnLogar" value="Logar no sistema >>"></td> </tr> </table></form>autentica.php PHP [/tr][tr]<?//CONECTA COM O BANCO DE DADOS require_once("conecta.php"); //RECEBE OS DADOS DO FORMULÁRIO $usuario = $_POST[txtUser]; $senha = $_POST[txtSenha]; //VERIFICA $sql = mysql_query(" SELECT A.ID_USUARIO, A.NOME_USUARIO FROM tb_usuarios A WHERE A.USUARIO = '$usuario' AND A.SENHA = '$senha'") or die("ERRO NO COMANDO SQL"); //LINHAS AFETADAS PELA CONSULTA $row = mysql_num_rows($sql); //VERIFICA SE RETORNOU ALGO if($row == 0) echo "Usuário/Senha inválidos"; else { //PEGA OS DADOS $id = mysql_result($sql, 0, "ID_USUARIO"); $nome = mysql_result($sql, 0, "NOME_USUARIO"); //INICIALIZA A SESSÃO session_start(); //GRAVA AS VARIÁVEIS NA SESSÃO $_SESSION[id] = $id; $_SESSION[nome] = $nome; //REDIRECIONA PARA A PÁGINA QUE VAI EXIBIR OS PRODUTOS Header("Location: resultado.php"); }//FECHA ELSE ?> [/tr] Agradeço desde já qualquer ajuda! Obrigado! Compartilhar este post Link para o post Compartilhar em outros sites
Fabyo 66 Denunciar post Postado Março 18, 2005 ve se ta configurado a pasta tmp no php.ini e sobre esses erros é porque esqueceram das aspas [""] exemplo $usuario = $_POST["txtUser"]; Compartilhar este post Link para o post Compartilhar em outros sites
nuboza 0 Denunciar post Postado Março 18, 2005 ve se ta configurado a pasta tmp no php.ini e sobre esses erros é porque esqueceram das aspas [""] exemplo $usuario = $_POST["txtUser"]; Valeu Fabyo o problema era esse mesmo das aspas .. obrigado pela ajuda! Compartilhar este post Link para o post Compartilhar em outros sites