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";

}

 

?>

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.