Check username
Posted: Sun Jul 08, 2007 6:05 am
Hi, I have a join form on my site. Beside the username field is a button called "check username". If a user clicks this button, a new small window opens in the center of the screen and it allows the user to type in a username to check if it is available.
Is there a way that i can just click the button on the form, and instead of opening up a new small window, the button will just check the username that the user has typed into the username field on the form. This will save the user having to type the username into the new window again when it opens.
Here is the code that the small window performs for checking the username
Surely there is someway i can put this sort of code into my join.php (join form) page... i'm not sure how or if that is the best way to do it, please help... thanks in advance
Is there a way that i can just click the button on the form, and instead of opening up a new small window, the button will just check the username that the user has typed into the username field on the form. This will save the user having to type the username into the new window again when it opens.
Here is the code that the small window performs for checking the username
Code: Select all
$username = mysql_real_escape_string($_POST['username']);
$check = mysql_query("SELECT username FROM accounts WHERE username = '$username'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
echo(sorry, username is in use);
}
else
{
echo(username is available);
}