My little script isn’t working, I can’t figure this out…
If you echo ‘true’; on check.php it works otherwise it doesn’t
<html>
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#submit").hide();
$.post("check.php", { username: $("#username").val(), password: $("#password").val() }, function(result) {
if(result == "true") { $("#submit").show(); }});
});
</script>
</head>
<body>
<form method="post">
Username <input type="text" id="username" name="username" />
Password <input type="password" id="password" name="password" />
<input type="submit" name="submit" id="submit" value="Login" />
</form>
</body>
</html>
check.php
<?php
mysql_connect('localhost', '', '');
mysql_select_db('database');
if(mysql_num_rows(mysql_query("SELECT username,password FROM users WHERE username = '". mysql_real_escape_string($_POST['username']) . "',password = '".mysql_real_escape_string($_POST['password'])."'")) > 0)
{
echo "true";
}
else
{
echo "false";
}
?>
Error in MYSQL you have
,instead ofANDShould read:
Not: