I am trying to create a function that will check if a user is subscribed or not, but the code doesn't work, it doesn't return TRUE
even if the user is subscribed.
Here is an example of my code.
function is_subscribed($email)
{
global $DBC;
$result = mysqli_query($DBC,"SELECT * FROM users WHERE email = $email");
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result)) {
if($row['subscribed'] == 'yes') {
return TRUE;
} else {
return FALSE;
}
}
}
}
$user_email = $_SESSION['email'];
if(is_subscribed($user_email)) {
echo "YES!";
}