Hello,
Everything works fine except for the prevention of duplicate emails. It appears that there is an error in the process-signup.php. The code was copied directly from the source provided. Perhaps, I inadvertently added or omitted a character.
ERROR RECEIVED when a duplicate email was added for a new user:
Fatal error: Uncaught mysqli_sql_exception: Duplicate entry 'hal@mail.com' for key 'email' in C:\xampp\htdocs\php-signup-login-main\process-signup.php:45 Stack trace: #0 C:\xampp\htdocs\php-signup-login-main\process-signup.php(45): mysqli_stmt->execute() #1 {main} thrown in C:\xampp\htdocs\php-signup-login-main\process-signup.php on line 45
This is the code for http://localhost/php-signup-login-main/process-signup.php:
stmt_init();
if ( ! $stmt->prepare($sql)) {
die("SQL error: " . $mysqli->error);
}
$stmt->bind_param("sss",
$_POST["name"],
$_POST["email"],
$password_hash);
if ($stmt->execute()) {
header("Location: signup-success.html");
exit;
} else {
if ($mysqli->errno === 1062) {
die("email already taken");
} else {
die($mysqli->error . " " . $mysqli->errno);
}
}
Hello,
Everything works fine except for the prevention of duplicate emails. It appears that there is an error in the process-signup.php. The code was copied directly from the source provided. Perhaps, I inadvertently added or omitted a character.
ERROR RECEIVED when a duplicate email was added for a new user:
Fatal error: Uncaught mysqli_sql_exception: Duplicate entry 'hal@mail.com' for key 'email' in C:\xampp\htdocs\php-signup-login-main\process-signup.php:45 Stack trace: #0 C:\xampp\htdocs\php-signup-login-main\process-signup.php(45): mysqli_stmt->execute() #1 {main} thrown in C:\xampp\htdocs\php-signup-login-main\process-signup.php on line 45
This is the code for http://localhost/php-signup-login-main/process-signup.php:
stmt_init(); if ( ! $stmt->prepare($sql)) { die("SQL error: " . $mysqli->error); } $stmt->bind_param("sss", $_POST["name"], $_POST["email"], $password_hash); if ($stmt->execute()) { header("Location: signup-success.html"); exit; } else { if ($mysqli->errno === 1062) { die("email already taken"); } else { die($mysqli->error . " " . $mysqli->errno); } }