Re: Login variable is empty but password is OK. Why? (newbie question)

From: Date: Wed, 21 Jan 2004 21:08:29 +0000
Subject: Re: Login variable is empty but password is OK. Why? (newbie question)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175340@lists.php.net to get a copy of this message
Flavio wrote:
My code is simply to login. I have two files: login.html (form) and login.php to validate. I don´t understand why php capture only password )I call it senha) and take a blank username (I call it nome). Any idea? #Code - login.html <form method="POST" action="login.php"> ... <input type="text" name="nome"> <input type="password" name="senha"> <input type="submit" name="Submit" value="Enviar"> <input type="reset" name="Submit2" value="Limpar"> ... #Code: login.php <? include('conecta.inc.php') ; $cod=md5($senha); $sql = "SELECT * FROM usuario where nome='$nome' AND senha='$cod'""; $tarefa=mysql_query($sql); $num=mysql_numrows($tarefa); $i=0; if ($num < 1) { header("Location:login.html"); } else { while ($num > $i) { $nome = mysql_result($tarefa,$i,"nome"); $tipo = mysql_result($tarefa,$i,"tipo"); $i++; } setcookie("nome", "$nome"); setcookie("tipo", "$tipo"); header("Location:index.php"); } ?> Are you shure that password is sent over also, because you will stil get an md5 hash on an empty string, meaning that even if $senha is empty you $cod wil produce a md5 hash.
Try fetching your username and password with the post array, that would be $_POST['nome'] and $_POST['senha']. /Martin

« previous php.general (#175340) next »