Im coding a php chat and I recently added activated field. It works right but the error message displays 24/7.
I have tried the else tag, used 'no' in activated tabel, redefined it to the $result
.
$result = mysqli_query($conn , "SELECT * from user where email='$email' and password='$password' and activated = 'yes' ");
while($row = mysqli_fetch_assoc($result))
{
$_SESSION['email'] = $row['email'];
$_SESSION['password'] = $row['password'];
$_SESSION['name'] = $row['name'];
}
if(mysqli_num_rows($result)>0){
$query = mysqli_query($conn, "UPDATE user SET status = 'Online' WHERE email = '$email' ");
header('location: index.php');
}
else {
echo "<font color='red'><p align='center'>Incorrect Email or Password</p>";
}
$activated = $result;
if($activated == 'yes'){
} else {
//This is the Activated Error that's not working.
echo "<font color='red'><p align='center'>Your Account Has Been Suspended</p>";
}
I want the error message to only display if the users account is suspended, but the result I get is the message displays to all users and there accounts are not suspended.