Originally Posted by tangoforce
If you set the column to unique and try to insert an existing user, the sql server won't insert it. You can then test whether or not the user was inserted by using mysql_num_rows() which will tell you how many rows were inserted - of course if there were none due to the username already existing then it will be 0.
or you just test whether the query suceeded. mysql_query() returns false on any DB/query error (like such a constraint violation).