Query used in checking existing users not working
if( empty($errors)){ //if errors free $password_encrypt = md5($password); $query = "INSERT INTO `users`(user_id,firstname, lastname, password, email, phone_num) VALUES (default,'$firstname','$lastname','$password_encrypt','$emailaddress', '$phonenumber')"; $run_query = mysqli_query($dbconn,$query); //we need to check if a user does not already exist with the same email and or phone number $check_existing_user = "SELECT * FROM `users` WHERE email = '$emailaddress' AND phone_num = '$phonenumber'"; $result = mysqli_query($dbconn, $check_existing_user); if($result){ $numofrows = mysqli_num_rows($result); if($numofrows > 0){ echo "address or phone number already exist"; } } if($run_query == TRUE){ header('Location: registersuccess.php'); } else{ echo mysqli_error(); }