I am working on a simple login. One piece of logic is that if the username does not exist then they get an error message and they get redirected to a registration page. However when I run my code I keep getting the error described above and no matter what I enter as a username it still comes back as true.
$res = $mysqli->query("SELECT Count(`userID`) FROM `users` WHERE `UserName` = '$username'");
if($res ==0){
return false;
}
else
return true;
}
I control the database as I'm developing it and thus know what usernames are in it. I was under the impression that if I put in a username that was in the database the count would be 1 and thus would return true, likewise if I entered a name that is not in the database then the count would be 0 and thus $res would be false?