Entry
How can I check that a username entered by someone into a form is unique and if not choose another?
Nov 24th, 2001 16:26
Jake Edstrom, Lorna Heffernan,
Assuming you're using a database to store user login information you
would most likely want to use an SQL statement similar to the following:
select count(*) as count from users_table where
username='$form_username';
Then fetch the result (mysql_fecth_array() if you're using MySQL for
example) and check to see if it is greater than 0. If so then someone
already has that username and you should inform the current user that
they should try a different name.