I am having problem with this login form. It is not letting me login to next page. It shows me if email and password match but it just doesn't let me log in. Please have a look and tell me what is wrong with it or suggest me something that will work. Thank you
HTML CODE
<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 CODE
$(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 CODE
<?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";
}
?>