Am Working on LOGIN form in a popup.. when form submitted it is returning to validations and displaying errors but i want to compare with database with in the pop up and display error message if login and password not matched for this i had tried with ajax to get the email and password compared with DB..
JS:
function login_validation(){
//worked with some validations like empty string and email filter...they are working fine displaying errors
$(document).ready(function(){
$("#upwd").on("focusout",function(){
var uemail = $("#uemail").val();
var upwd = $("#upwd").val();
$.ajax({
type: "POST",
url: "checkl_login.php",
data: 'uemail='+uemail+'&upwd='+upwd,
success: function(msg){
$('#status').html(msg);
return false;
}
});
});
});
}
HTML:
<form name="f" method="POST" action='' onsubmit="return login_validation()">
<p><input type="text" placeholder="Email" name="uemail" id="uemail" > </p><span id="uemailerror"></span>
<p><input type="password" placeholder="password" name="upwd" id="upwd" ><span id="upassworderror"></span><span id="status"></span>
<!--submit button.. -->
PHP, checkl_login.php:
ob_start();
session_start();
include('dbconnect.php');
include('gettime_diff.php');
mysql_select_db("hccommunity") or die(mysql_error());
if($_POST['uemail'] && $_POST['upwd']){
$loginemail = mysql_escape_string($_POST['uemail']);
$loginpwd = mysql_escape_string($_POST['upwd']);
$search = mysql_query("SELECT * FROM user WHERE email='".$loginemail."' AND password='". mysql_escape_string(md5($loginpwd)) ."'") or die(mysql_error());
$match = mysql_num_rows($search);
if($match > 0){
echo "OK";
}
else{
echo "ERROR";
}
}
the form is not displaying the "error" or "ok" message....