Jump to content

getting error in this useravailability check code


bindiya

Recommended Posts

I am writing a code using jquery in a php page to check the username availabiltiy,but getting error ie every time username is available is the message i am getting.

 

the code is

 

$(document).ready(function()

{

$("#username").blur(function()

{

//remove all the class add the messagebox classes and start fading

$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");

//check the username exists or not from ajax

//$.post("themes/user_availability.php",{ username:$(this).val() } ,function(data)

        $.post("themes/user_availability.php",{username:$(this).val() } ,function(data)

{

  if(data=="no") //if username not avaiable

  {

$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox

{

  //add message and change the class of the box and start fading

  $(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);

});

          }

  if(data=="yes")

  {

  $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox

{

  //add message and change the class of the box and start fading

  $(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);

});

 

  }

 

        });

 

});

});

 

php file user_availability.php

<?php

$login=$_POST['username'];

$sql="select username from web_payregister where username='$login'";

$result=mysql_query($sql);

if(mysql_num_rows($result)>0){

 

echo "no";

}else{

echo "yes";

}

 

?>

 

OK... try the following and post the result you get...

change your php code to this and run it once to see what it returns...

$login=$_POST['username'];
echo $login;
/* $sql="select username from web_payregister where username='$login'";
$result=mysql_query($sql);
if(mysql_num_rows($result)>0){

echo "no";
}else{
echo "yes"; 
}*/
Sorry try this ... the one before what give you another kind of error 

and post it here so we can see where the problem is!

<form name='registration' action='' method='post' onsubmit="return verify();">

 

 

<table width="599" align='center'>

 

<tr><td  colspan='5'></td></tr>

<tr><td width="33"></td>

<td width="187">

User Name <font color="#CC0000">*</font></sup>

</td>

<td width="22">:</td>

<td width="148">

<div> <input name="username" type="text" id="username" value="" maxlength="15" /><span id="msgbox" style="display:none"></span></div></td><td width="185"></td>

</tr>

<tr><td width="33"></td>

<td width="187">Password<sup><font color="#CC0000">*</font></sup></td>

<td width="22">:</td>

<td width="148"><input name="password" type='text' /></td><td></td></tr>

</table></form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.