Iβm working on a web application, and the moment I submit forms that are unique to the user,
MySQLIntegrityConstraintViolationException Duplicate entry -'username '
for key 'PRIMARY'
I am well aware why this happens because I am trying to enter a double entry into the database with the same primary key. I would appreciate no comment on this, as this may be redundant.
What I'm really asking is how should I handle this. I tried to catch this exception, but apparently my lack of experience caught up with me.
I would be grateful for your help.
Is there a better way to check for duplicate records in a database?
For example, should I do what I do when checking for duplicate items and just do a database check for a matching username and password?
thank
source
share