Check If Username Exist

Discussion in 'JavaScript' started by leon_king, Jul 13, 2007.

  1. #1
    Hi guys,

    I need help on my script, im using ajax on my signup form and an alert message pop up when theres an empty fields.
    How can i check my database if the username entered already exist in the database using javascipt
    and an alert message will pop up when username already exist?
    is it possible to to use php inside javascipt to check the database if the username already exist.
    im an ajax newbie. Pls help me think of any solution with this problem.

    Thanks in advance.
     
    leon_king, Jul 13, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here's an example using a SELECT query. You can modify it to return, say, a 1 or a 0, if the user name already exists, or doesn't.

    You can use the onblur event for the userName text field to call the AJAX function, when the user tabs away from the field:

    <input type="text" name="userName" onblur="update(this.value)">

    http://ajaxforums.net/index.php?topic=858.0
     
    Mike H., Jul 13, 2007 IP