#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2009
    Posts
    26
    Rep Power
    0

    Verify userID not already in use


    What is the best way to verify that a userID is not allready being used?

    I was thinking Javascript but can't find where it will check the DB.

    I am using PHP, MySql
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,129
    Rep Power
    1990
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2009
    Posts
    26
    Rep Power
    0
    Thanks, I did find an Ajax code that does this!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2010
    Posts
    10
    Rep Power
    0
    What is the best way to verify that a userID is not allready being used?
    in ur mysql you should have userID as incremental which each time you insert new data it will give them the next avail id

IMN logo majestic logo threadwatch logo seochat tools logo