You can use primary keys here too, but if you are adding a new user (in this case), then the key isn't set yet anyhow until the record is added. (like in MS Access) In this case, we want to make sure the user name is unique. The primary key should be an auto-increment primary key so it is (by design) going to be unique.
What you would have to do is to run a query first to determine if that user name already exists, and if it does, then echo back a reply to say it already exists and give a back link, and then don't run the insert query.
If the user name doesn't already exist, then run the insert query, and proceed from there. You can leave the count portion of the query just as a double check to make sure the data was added after you verify it isn't a duplicate.
~DR