|
|
Posted by Gleep on 01/02/07 04:14
On Mon, 1 Jan 2007 14:24:34 +0200, "Nakkie" <nakkie@telkomsa.net> wrote:
>Hi
>
>Has anyone experienced this problem before?
>I created a simple login page using an HTML form.
>PHP check the username and password against a .txt file.
>The authentication part is doing what it's supposed to do with both valid
>and invalid details.
>The problem comes in when I leave both fields blank and click the login
>button - it authenticates...... and take me to the restircetd area....
>I have created a password for a blank username as well as a space, but it
>stil does the same.
>Any idea how to fix this?
>
you need to validate that the fields are filled out first, if not - don't do any processing
$username = $_POST['username'];
$password = $_POST['password'];
if($_POST['Submit']) {
if(empty($username) OR empty($password)) {
$errorNote = "Username and Password are required";
exit;
} else {
test the username and password
}
} // end of submit
// somewhere on the page
echo $errorNote;
this will give you the general idea, adapt to your needs.
Navigation:
[Reply to this message]
|