Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to display the message "email already exist" #1

Open
saqihussainkalan opened this issue Aug 27, 2022 · 5 comments
Open

Not able to display the message "email already exist" #1

saqihussainkalan opened this issue Aug 27, 2022 · 5 comments

Comments

@saqihussainkalan
Copy link

signup-process.php : an error occurred in mentioned file,
why these lines of codes doesn't work
}else {
if ($mysqli->errno === 1062) {
die("email already taken");
} else {
die($mysqli->error." ".$mysqli->errno);
}
}

@daveh
Copy link
Owner

daveh commented Aug 28, 2022

What exactly is the error that you get?

@ProGen18
Copy link

ProGen18 commented Oct 15, 2022

it's because you have to replace :
$mysqli = new mysqli(hostname: $host, username: $username, password: $password, database: $dbname);

by :
$mysqli = new mysqli($host_name, $user_name, $password, $database);

I hope this was useful to you 😃

@daveh
Copy link
Owner

daveh commented Oct 15, 2022

Just to be clear, the above fix is only if you're using a version of PHP prior to version 8. Named arguments are supported from PHP 8 onwards.

@BADBOY303
Copy link

signup-process.php : an error occurred in mentioned file,

Error showed in browser:

Fatal error: Uncaught mysqli_sql_exception: Duplicate entry '[email protected]' 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

Mentioned error line:
why these lines of codes doesn't work

if ($stmt->execute()) {

header("Location: signup-success.html");
exit;

} else {

if ($mysqli->errno === 1062) {
    die("email already taken");
} else {
    die($mysqli->error . " " . $mysqli->errno);
}

}

@daveh
Copy link
Owner

daveh commented Dec 26, 2022

Please see this issue to see if any of the fixes there work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants