0

I have the very basic code for registration a new user.

if ($email != "" and $password != "") {
$statement = $pdo->prepare("INSERT INTO Users (email, password) VALUES (?, ?)");
$statement->execute(array($email, $password));  
echo "<br>";

if try to register the same email a second time, I get the following Error Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

My question is, how can I hide this message from the user and instead display a generic Error message like "user is taken"

With best regards

Nigel Ren
  • 53,991
  • 11
  • 38
  • 52
  • to hide ALL error messages from a user, simply add display_errors=0 to php.ini. And to prevent this error you can simply select this email first – Your Common Sense May 29 '22 at 17:31

0 Answers0