Jump to content

Check user against database


SaraLynn

Recommended Posts

Hi,Can someone tell me how to make my register form check my MySQL database when someone signs upon my site to see if the username is available?. Currenly it has no error checking so the same usename can be registed over and over again.thanks so much,Sara Lynn

Link to comment
Share on other sites

before you insert the user into the database do a select statement to get a list of all the users in the user table. Then use a for loop to see if the provided username already exists in the return results array.

Link to comment
Share on other sites

or, you can do a select query to search the username from the database, get the result and use mysql_num_rows to see if that user name, is either 1, it exists, or 0, its open. That might be alot easier!

Link to comment
Share on other sites

or, you can do a select query to search the username from the database, get the result and use mysql_num_rows to see if that user name, is either 1, it exists, or 0, its open. That might be alot easier!
Yeah that would be more efficient too.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...