The following code is supposed to go to page x if the username and password are found on the database. It goes to page x even if details are wrong. Can someone please tell me what's wrong.
<?php
if (headers_sent() ) {
print("cannot process your request due to a system error!\n");
}else{
include "db.php";
if (($username) AND ($password)) {
$validate = "SELECT username, password FROM users WHERE username=='$username' AND password=='$password'";
$result = mysql_query($validate);
header ("location: index.php?username=$username");
exit;
}else{
header ("location: login.php?message=invalid");
exit;
}
}
?>
<form action="<?php echo $PHP_SELF; ?>" method="POST">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Submit">
</form>
</body>