Skip to content

Prevention of Duplicate Emails Not Working Properly #12

@techangela1

Description

@techangela1

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); } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions