I created a very simple login page where I validate the username and password on PHP after submitting the form.
My first step in the validation is to check that the username and password are not empty, if empty I send the user back to the login page:
$e = $_POST['email'];
$p = $_POST['password'];
if($e == '' || $p == '' || is_null($e) || is_null($p)){
header('Location: login.php?e=missing');
}
it turns out that the if statement that checks if the username and password are empty only works if I add an else statement:
$e = $_POST['email'];
$p = $_POST['password'];
if($e == '' || $p == '' || is_null($e) || is_null($p)){
header('Location: login.php?e=missing');
}else{
//more validation
}
To be honest, my code works, I added the else and problem solved, but WHY???
Thanks.
1 Answer