Skip to content
Advertisement

how to avoid duplicate entries

I created a form on my website where the user can create an account. I save everything into a database connected to a website. This is how I created a table:

Since users would use the email and password to later login to the website, I don’t want duplicated email entries. Now my question is should I make column email unique inside my table or should I check if the inputted email already exists in the database (with PHP)? Is there even any difference?

Advertisement

Answer

Making the email and username as unique for example

of course you must also check it in your application, but this will prevent it.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement