So I am trying to check if a user is banned using a mysqli query however it always seems to return that the user is banned. Even though they are not banned.
user_banned function
function user_banned ($con, $username) {
$data = $username;
$username = sanitize($data, $con);
$username = $data;
mysqli_query($con, "SELECT `banned` FROM `users` WHERE `username` = '$username'");
return(mysqli_affected_rows($con) == 1) ? true : false;
}
Place where I call the function:
$username = $_POST['username'];
$password = $_POST['password'];
if (user_banned($con, $username) === true ) {
$errors[] = 'You are banned, contact an admin.';
}
I have echo'd the $username and it is the correct username, so that is not the issue.
TL;dr function always returns true for some reason.