Oops, forgot to explain 🙂
The page has a function doCheck, if it's enabled, it checks whether or not you entered the right username/password. If it's disabled ($doCheck doesn't exist yet (!isset($docheck)) it just gives you the login form. This form has a hidden input called doCheck, when you submit this form, the variable $doCheck will have the value 1. So, it returns to this same php3 file (called it self.php3, call it how you want) with $doCheck=1 and will check the login+password. The header() function makes sure you are being directed to the right page after your authentification was correct.
Evaugh wrote:
Hey,
Make your form something like:
<?php
if (!isset($doCheck)) { ?>
blablabla, some html page
...
<form method="post" action="./self.php3">
<input type="hidden" name="doCheck" value="1">
<input type="textfield" name="name">
<input type="password" name="password">
</form>
...
<?php
}
else
{
if ($name == "John")
&& ($password == "airplane") {
header("Location: http://where/you/want/the/user/to/go");
}
else {
print "<H1>Sorry, wrong username and password</H1>";
}
}
?>
But why not use .htaccess?