So in my database I am having trouble with the syntax for searching my database and getting my program to do what I want. I want to see if the email entered already exists in the database, and if it does I want to stop the signup process and tell the user to use a different email to sign up. This is the code im having trouble with
//check to see if email is available
$check_email = "SELECT COUNT(*) FROM users WHERE email = $email";
if(mysqli_query($db, $check_email) >= 1){
echo 'Email in use, try another email';
}else{
//continue to insert data into users table
}
I know it is connected to the database because I've already inserted users in the table like this before I added this filter to find emails which already exist. What logic should I use to make the above code snippet do what I am aiming for?