Browse this blog

Thursday, September 17, 2009

Header ("Location: ")

This PHP-command could be very useful if you're coding a passord request. 

On the one hand you can use it to forward to the login site if the password or user name is wrong or on the other hand you can use it to forward the user to the "secret" site if the password and the user name is correct.

A little example:

$username = $_POST["username"];
$passwort = $_POST["passwort"];

if ($username=="++++" && $passwort=="++++")
{
Header ("Location: bilder.html");
}

else
{,
Header ("Location: index.html");
}

?>

Here are first defined the variables coming from a form on my login page, then checked if the password and the user name is correct. If this is true you will be forwarded to the "secret" page and if user name or password is wrong, you will be forwarded back to the login page. 

No comments:

Post a Comment