EngineeringEngineering note
The Sign-Up Page Went Blank When an Email Already Existed
The code for this case was there. It just never ran any more, and errors were hidden, so nobody saw why.
Author
DueClix Engineering
Published
Reading time
1 min read
A person filled in a sign-up form and pressed the button. The next page was completely white. No message, no account, and no way to know what to do.
The cause was ordinary: their email was already registered.
Why the page was blank
The database allows each email once. The old code tried to save the user and then looked for error number 1062, which means a duplicate. If it found it, it was meant to show a friendly message.
Since PHP 8.1, PHP's mysqli database tool throws an exception by default when a query fails. The script stopped on the save line, so the check below it never ran. The page also had error display turned off, so the visitor saw nothing.
// Old style: never reaches the if when mysqli throws
$ok = mysqli_query($db, $sql);
if (!$ok && mysqli_errno($db) === 1062) {
$message = 'This email is already registered.';
}What we changed
- Check first. The form looks for the email before saving.
- Catch the error too. Two people can submit at the same moment, so the check alone is not enough.
- Tell the user early. The form checks the email when they leave the box.
- Keep what they typed. After an error, the fields are still filled in.
try {
$stmt->execute();
} catch (mysqli_sql_exception $e) {
if ($e->getCode() !== 1062) {
throw $e;
}
$message = 'This email is already registered.';
}One trade-off
Telling people an email exists is helpful, but it also lets a stranger find out who has an account. For a private service, show a neutral message and send the details by email. At the least, limit how often one visitor can ask.
Test your own form
- Sign up with an email that already exists.
- Press the button twice quickly.
- Leave a required box empty.
- After each error, check that your typed details are still there.
- Look in the server error log after a PHP upgrade, not only at the page.
If a form on your site sometimes does nothing, tell us which page. We will test it the way a visitor would.
Sources
- Our own sign-up fix, 21 November 2026. The site is not named.
- PHP Manual, mysqli_report, for the PHP 8.1 change.