How to change the database error prompt to js?
Use if (insert statement) {echo "<script>alert('This data already exists')</script>"}
insert If the statement encounters a duplicate unique key, it will not return false but directly display a database error
try catch I usually set a unique primary key and check to see if there are duplicates before inserting
insert ignore into ·table· ...plus ignore
try catch
try
{ //...}
catch(Exception $e)
{ //...}