Does anybody know how to correct this code so that it identifies whether an email already exists in the database and display an error. It is currently displaying the error message even if the email DOES NOT exist in the database -- therefore the form is not getting submitted:
$email = $_POST['email'];
//prepare and set the query and then execute it
$stmt = $conn2->prepare("SELECT COUNT(email) FROM users WHERE email = ?");
$stmt->bind_param('s', $email);
$stmt->execute();
// grab the result
$stmt->store_result();
// get the count
$numRows = $stmt->num_rows();
if( $numRows )
{
$errors = true;
echo "<p class='red'>Email is already registered with us</p>";
}
else
//if we have no errors, do the SQL