title: log into website
body: <p>I'm designing a website where the user logs in. When creating accounts, I check to see if the username already exists. Should this checking be done inside the scripts or should I make the username a primary key of the table? I'm using MySQL and PHP.</p>
  
  <p>So should I write a script that queries the database to check to see if the supplied username is already in use or should I try inserting the given user name and  have the field as a primary key and if it fails it means that the user name is in use?</p>