jquery ajax form function(data)

Posted by RussP on Stack Overflow See other posts from Stack Overflow or by RussP
Published on 2010-04-15T12:24:54Z Indexed on 2010/04/15 12:33 UTC
Read the original article Hit count: 204

Filed under:
|
|

Can some one please tell me where I have gone wrong. What ever I do I get the answer "no"

JQuery to send data to php query

 $j.post("logincheck.php",{ 
username:$j('#username').attr('value'),
password:$j('#password').attr('value'),
rand:Math.random() } ,
function(data) {
  if(data=='yes') {alert('yes');}
  else {alert('no');}
  }
 );

Here is the php query

if(isset($_POST['username'])):
$username  = $_POST['username'];
$password  = $_POST['password'];
$posts   = mysql_query("SELECT * FROM users WHERE username='$username'");
$no_rows  = mysql_num_rows($posts );
while($row  = mysql_fetch_array($posts)): 
print 'yes';
endwhile;
else:
print 'no';
//header('location: index.php');
endif;
endif;

Thank in adance

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about form