while ($stmt->fetch()) {
if ($teacherusername == $dbTeacherUsername && $teacherpassword == $dbTeacherPassword) {
if ($dbActive == 1) {
$loggedIn = true;
} else if ($dbActive == 0) {
$loggedIn = false;
echo "You Must Activate Your Account from Email to Login";
}
}
}
if ($loggedIn == false && $_POST) {
echo "The Username or Password that you Entered is not Valid. Try Entering it Again";
}
In the code above, I have a problem displaying a message and I cannot seem to figure out what I am doing wrong. If the user enters in either the wrong password or username, then it displays the message
"The Username or Password that you Entered is not Valid. Try Entering it Again".
This is fine, but if the $dbActive = 0, it should only display the message
You Must Activate Your Account from Email to Login.
But instead it is displaying both messages when this happens so it instead displays
You Must Activate Your Account from Email to LoginThe Username or Password that you Entered is not Valid. Try Entering it Again.
I know why this is happening, but I cannot seem to figure it out. How can I stop it from getting both messages to be displayed if $dbActive = 0?
Your code explains everything pretty clearly:
So how do we fix this? Easy! We add another variable declaring whether or not the user is active.