Gmail Style, AJAX Check Username Signup

I have made an example of the Gmail username style signup page. Where you enter your selected username and click Check Username the script will then check to see if the username is taken if so make some suggestions as to others like that one which are available.

The example uses PHP and AJAX (via Sajax development version) to complete this task.

You can see the example and see the source code.

48 Responses to “Gmail Style, AJAX Check Username Signup”

  1. karim Says:

    I simply love the demo! That’s Ajax or stay with ya mom’ :)

  2. Juan Says:

    Would it be possible to make it check for the username automatically and also mergin it with the suggestion if the name is alredy taken without having to submit the form?

  3. xaero Says:

    wonderful!

  4. Imran Sayed Says:

    it shld chk for username in realtime w/o pressing the [Check Username] button.

  5. mypapit Says:

    cool stuff, i like it. I’ve just started learning AJAX, and your website is very helpful

  6. chris Says:

    AWSOME, thanks for the script man, much appreciated :-D

  7. Dappie Says:

    to make it check in realtime: don’t use the onPress, instead use a onBlur=”check_user_exist(); return false;” at the input field. Script works fine!

  8. Stan Says:

    This is exactly what I’m looking for, thanks.

  9. Andrew Says:

    I got inspired by your code to make a simple AJAX login.
    Username and password with a submit button.

    anyways, just wanted to post some code in case someone is curious how it works with SAJAX.

    Untitled Document

    function do_getUserId(username){

    if (username==0) {
    document.getElementById(’loggedout’).style.display = ‘none’;
    document.getElementById(’loggedin’).style.display = ‘block’;
    }
    if (username==1){
    document.getElementById(’loggedin’).style.display = ‘none’;
    document.getElementById(’loggedout’).style.display = ‘block’;
    var str = ‘Sorry that username is not found ‘;
    document.getElementById(’loggedout’).innerHTML = str;
    }
    if (username==2){
    document.getElementById(’loggedin’).style.display = ‘none’;
    document.getElementById(’loggedout’).style.display = ‘block’;
    var str = ‘Sorry the password is wrong, enter again ‘;
    document.getElementById(’loggedout’).innerHTML = str;
    }
    }

    function getUserId(){
    var x,y;
    x = document.getElementById(”username”).value;
    y = document.getElementById(”password”).value;
    x_getUserId(x,y,do_getUserId);
    }

    #loggedin {
    display: none;
    color: grey;
    }
    #loggedout {
    display: none;
    color: red;
    }

    Username

    Password

    User is logged in!

    Sorry that username/password is not found.

  10. BlogOnRails.com Says:

    Comprobando nicks con AJAX.

    Son muchas la páginas que cuando vas a escribir el nombre de usuario con el que quieres registrarte, te muestran al lado un botón para comprobar si dicho nombre está ya ocupado o no, y si lo está te muestra una lista con posibles nombres que no lo…

  11. Rock Says:

    Hi Andrew.

    It dint work. Can u give me the proper version. I would like to see. Im juz a novice. Sorry if i’m wrong. Plz clear it.

  12. Roshan Says:

    Hey,

    Can you tell me how to get this working with mod rewrites? Right now how my system works is mydomain.com/register.php shows as mydomain.com/register. When I try the script at mydomain.com/register.php (without the rewrite) it works fine but when I try it at mydomain.com/register (with mod rewrite) it does not. If you can help me that would be great, I have left my email. I really want to use this on my website but I need to have it working with the rewrites.

    Thanks

  13. Marian Says:

    Nice one.. thanks for the demo -, I’m developing a portal, I’m novice to ajax, this is exactly what I was looking for.

    Thanks again.
    Marian

  14. Peter Says:

    Great example!

    I created a very nice user registration system using instant ajax validation.

  15. Viet Ng Says:

    Does anyone know a similar perl script to do this, like as the one on ebay.
    Thanks

  16. Vinit Says:

    Cool Man, Thanks
    I was looking for this coding from many weeks.
    I am looking for wordpress type comment coding :D
    Vinit

  17. Hardbyte Says:

    Hi, fantastic! But is there a kind of addon where it doesnt allow alphanumeric - / : ” £$%^ and things?

  18. Nick Says:

    Excellent code.
    I have made modifications to this and can do many things with it… however one thing I cannot do is check boxes. It always says it is on even though it is not.

  19. Aziz A. Khan Says:

    Hi,

    Thank you very much for providing such a brilliant idea, its really works great.

    thank you again
    best regards,
    Aziz A. Khan

  20. Angie Says:

    Any coding on trim the user_name between database field name & text box?

  21. Angie Says:

    Postgres database support this?I try on my side. Unfortunately, case sensitive check was failed. Anyone can help me on that.

    Thanks Thanks!

  22. icejack Says:

    thanks the script is nice, but i currently have a problem, my url is type www.2vif.com/newuser/new.php?K=xxxx
    usin this generate an error, could you help me? am a real newbie in ajax….

  23. John Says:

    A problem which you discuss on your site is very important for me. Thank you for your resume.

  24. 煎蛋 » miniAjax:酷炫 DHTML 及 AJAX 大收集 Says:

    […] Gmail style, AJAX check username signup […]

  25. dailyrevolver.com » Blog Archive » MiniAjax Says:

    […] Gmail style, AJAX check username signup […]

  26. AjaxNedir » Blog Archive » MiniAjax.com Says:

    […] Gmail style, AJAX check username signup […]

  27. MiniAjax - esn studio Says:

    […] Gmail style, AJAX check username sign up […]

  28. ajaxcss.com Says:

    Gmail style, AJAX check username signup

    I have made an example of the Gmail username style signup page. Where you enter your selected username and click Check Username the script will then check to see if the username is taken if so make some suggestions as to others like that one which are …

  29. wahab Says:

    Is there a .asp version of this great script.
    I use .asp and ms access.
    if you have the same in .asp please mail me. I need it very hard.
    thanks in advance.

  30. Amardeep Singh Says:

    Its really a very nice script. this is my first implementation of ajax in my website.

    i really had a fun using this script. Very good script.

    Only one improvement which i want to have in this script, is that it should show available usernames suggesstion.

    it shows the username for a array, what if the username mentioned in that array is already taken.

    it should show the unique suggestions which are not already taken.

    rest a brilliant script.
    full credits to the person who has developed this script.

  31. patrick Says:

    is there an easy way to make it not suggest names and just say not available?

  32. manikandan Says:

    hi…

    i have one question in ajax concept..

    1.click the submit button display the database fields..

  33. askin yildiz Says:

    ı have user sytem where is error

    orginal code:
    $sql = “SELECT `username` FROM `users` WHERE `username` = ‘$username’”;

    my code :
    $sql = “SELECT `username` FROM “.$dbprefix.”`users` WHERE `username` = ‘$username’”;

    please help

  34. Tom Westcott Says:

    askin, the correct code is

    $sql = “SELECT `username` FROM “.$dbprefix.”.`users` WHERE `username` = ‘$username’”;

    notice the period (.) seperating the database name and table.

  35. askin yildiz Says:

    NOT WORKING :(

    my files..

    config.php

    login form :

    0) {

    // Username not available
    $avail[0] = ‘no’;
    $i = 2;
    // Loop through suggested ones checking them

    ………………………

    Error Text :

    +: Error :Table ‘test.musterikart’doesn’t exist

    why dbprefix not read ?

    $dbprefix = ‘xxx_’;

  36. Bobby Says:

    askin, try this code:

    $sql = ”
    SELECT `username`
    FROM ‘” . $dbprefix . “users`
    WHERE `username` = ‘$username’
    “;

    If you need a period (.) seperating the db prefix and table, just add it after the double quote (”).

  37. lynchmv Says:

    Can anyone figure out why it returns an error when using this in a lighbox? Check it on my site, the third link titled ‘User Check’ http://ajax.llpool.com

  38. lynchmv Says:

    OK, got it working. I had the php stuff coming after the headers so it was bombing out.

  39. jest_staffel Says:

    there is also a large and comprehensive database of 500+ ajax scripts available with over at ajaxflakes’s ajax scripts compound

    thought i should add it might be helpful to others…

  40. host india Says:

    excellent script, can such a script be available to check for domain availibility ?

  41. help me Says:

    please fix, it’s not working when i using charset=”utf-8″

  42. Eugene Says:

    Will this work in MediaWiki? If it does, whats the best way to implement this so when you type in the a word, it’ll prompt you whether a “Page” is taken or not?

  43. bigmountain Says:

    Is it possible to change this script around so that when it query the db for username and returns that one is taken, to have some code that will radomly pick from the ad ons instead of taking the first few available, if any are available.

    It would be really cool if you could have like 100 -200 suggestions in there and the script randomly picked 4 of the available.

  44. Farshad Says:

    hi , Thanks for your brilliant script

    i used it and it works fine ,, but when i implement it to other pages , i mean when i write :

    include(”username-ajax.php”);
    then :
    when i click on check button it shows me a error window with this content :

    http://www.mahlaghabonbon.com/error.gif

    any suggestion ?

    tanx

  45. abcmel Says:

    You are awesome, good job, keep it up, posted from HK

  46. Funny Interesting Facts | Weird |Science Yoga biza » Blog Archive » Ajax 30+ Great Resources Says:

    […] Gmail style, AJAX check username signup […]

  47. Web Design Magazine » AJAX-Solutions For Professional Coding Says:

    […] 30. GMail Ajax Style Username Signup […]

  48. Ajax und kostenlose scripts mit demo « Ajax scripts blog Says:

    […] Gmail style, AJAX check username signup […]

Leave a Reply

-->