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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to