Validate PHP login

Asked

Viewed 1,208 times

1

Good, I’m trying to log in to the small project and I’m having a hard time in case $login is correct go to shopping.html if it is wrong login or password appears wrong.

$login = mysql_query("SELECT Nome, Password FROM tb_utilizador WHERE Nome ='$Nome' AND Password = '$Password'");

if ($login = TRUE ) {


    header('location: Compras.html');
} else {

    // falhou o login
    echo "<p>Utilizador ou password invalidos. <a href=\"index.html\">Tente novamente</a></p>";
}

}

1 answer

2


Try that one form:

$login = mysql_query("SELECT Nome, Password FROM tb_utilizador WHERE Nome ='$Nome' AND Password = '$Password'");

$res = mysql_fetch_row($login);
   if($res)
   {
     header('location:compras.html');
   }

   else
   {
     header('location:error.php');
   }

The php error. will be the page where you will provide a message stating that the user and/or password are incorrect. In case that is not the page you just change the name shown. I just put php error. as an example for error

Browser other questions tagged

You are not signed in. Login or sign up in order to post.