[ad_1]
I have a small problem with an email validation. I want to check in the database if the email already exists but I always get the “Oops! Something went wrong. Please try again later.”, path. Does anyone see an error that I do not see? I would appreciate your help!
//Validate email
if(empty(trim($_POST["email"]))) {
$email_err = "Please enter a emailadress.";
} else{
// Prepare a select statement
$sql = "SELECT id FROM users WHERE email = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_email);
// Set parameters
$param_email = trim($_POST["email"]);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
/* store result */
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1){
$email_err = "This email is already taken.";
} else{
$email = trim($_POST["email"]);
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
[ad_2]