On the other hand you should add a 'unique' index to the table so the database will refuse to add duplicate data (for example, duplicate usernames)
Then after you insert (Note: after you insert) you will either get an 'ok' from mysql_query(), or mysql will throw an error mantioning something about 'cannot insert duplicate value for key bladebla'
Doing a select before inserting is bad, because this is a multi-user environment. It is very well possible that two people try to add a user with the same name, at the same time. Then the four queries (4!) would overlap and you'd have to check which queries worked anyway.