Handle error for duplicate entries - PHP/MySQL
PHP Snippet 1:
catch (PDOException $e) {
if(str_contains($e, '1062 Duplicate entry')) {
header("Location: login.php");
}
die("Error inserting user details into database: " . $e->getMessage());
}