username availability check

hi frds i am working on a project in which i need to check the username availability …
for that i am using script from a original poster
but its not working here is the script and php code plz help…

script:

Username availability Checking using jQuery body { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; } .top { margin-bottom: 15px; } .messagebox{ position:absolute; width:100px; margin-left:30px; border:1px solid #c93; background:#ffc; padding:3px; } .messageboxok{ position:absolute; width:auto; margin-left:30px; border:1px solid #349534; background:#C9FFCA; padding:3px; font-weight:bold; color:#008000; } .messageboxerror{ position:absolute; width:auto; margin-left:30px; border:1px solid #CC0000; background:#F7CBCA; padding:3px; font-weight:bold; color:#CC0000; }

Please move the focus out of the box to check the availability of username
User Name :

php code:

<?php mysql_connect('localhost','root','****') or die('There is error to connect to server:-'.mysqli_connect_error()); $db_selected = mysql_select_db('dailynotes'); $user_name=$_REQUEST['user_name']; $sql = "select * from userinformation2 where username='$user_name'"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $existing_users[] = $row['username']; } if (in_array($user_name, $existing_users)) { //user name is not availble echo "no"; } else { //user name is available echo "yes"; } ?>

You really shouldn’t fetch all usernames in order to find out if a username is taken. Example:

[php]$sql = “SELECT username FROM userinformation2 WHERE username=’$user_name’”;
$row = mysql_fetch_assoc(mysql_query($sql));

if ((boolean)$row[“username”]) {
// Username is taken
} else {
// Username is available
}
[/php]

thnx for your reply…
it means my javascript is working properly but php code has a problem …?
can your post me that php code plz…

No, the PHP seems like it should work. Do you know where it fails? Does anything happen?

Is all of this in one file or several? The PHP should be in a seperate file. What is the filename of the php file?

Go to your php file and add this to the address: ?username=somename
Does it echo “no” (if “somename” is available)?

I mean, add this to the address: ?user_name=somename

yeah i see that
and it was working fine…

but now i recheck the problem …

my javascript isn’t working in firefox…

i am using ubuntu linux…

for javascript checking i made this simple function but its not working…

Username:
In here

check5.php

data


but its not fetching the check5.php file data

where is the problem?

Sponsor our Newsletter | Privacy Policy | Terms of Service