我在使用此登录表单时遇到问题。它不允许我登录到下一页。它会告诉我电子邮件和密码是否匹配,但它只是不允许我登录。请看一下并告诉我它有什么问题或建议我一些可行的方法。谢谢
代码
<div id="loginForm">
<form id="formLogin" method="post" action="login.php" >
<input type="text" id="eMailTxt" placeholder="Email Address" />
<input type="password" id="passWordTxt" placeholder="password" />
<p></p>
<input type="submit" value="Login" id="submitBtn" class="Btn" />
</form>
</div>
jQuery AJAX 代码
$(document).ready(function(){
$("#formLogin").submit(function(){
$a = $("#eMailTxt").val();
$b = $("#passWordTxt").val();
$.post("loginCheck.php",{
email: $a,
pass: $b
},function(data){
if (data=="false")
{
$(".loginForm p").html("Password does not match").css({'color':'red'});
return false;
}
else
{
$(".loginForm p").html("Password match").css({'color':'green'});
$("#formLogin").submit(); //I've tried return true and this submit function but none worked.
}
});
return false;
//If I turn this true, it logs in everytime even if password doesn't match. And if it's false, it will return false everytime even if password is correct
});
});
PHP代码
<?php
$q=$_POST["email"];
$s=$_POST["pass"];
$con=mysqli_connect("localhost","root","","SocialNetwork");
$check="SELECT PassWord FROM people WHERE EMAIL = '".$q."'";
$data=mysqli_query($con,$check);
$result=mysqli_fetch_array($data);
if ($s != $result[0])
{
echo "false";
}
else
{
echo "true";
}
?>