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