January 18th, 2010, 02:38 PM
Verify userID not already in use
What is the best way to verify that a userID is not allready being used?
I am using PHP, MySql
January 29th, 2010, 01:50 AM
It depends on when you want to perform the check. Basically, there's two ways to do it:
1. Check on form submission.
This is the easy one. Whenthe form is submitted, check in the database to make sure that the requested username doesn't already exist, and if it does show an error the same way that you would with the rest of your form validation.
2. Check when entered.
To do this, you can use an AJAX query to get a response from the server and display this to the user when they are still on the page. It still needs to do the same thing of checking in the database to see if the username has been used before, but may help with the overhead of submitting the full form each time.
January 29th, 2010, 08:23 AM
Thanks, I did find an Ajax code that does this!
August 14th, 2010, 11:22 AM
in ur mysql you should have userID as incremental which each time you insert new data it will give them the next avail id