I want to convert this simple posting form into ajax posting form
I tried to do this but does could not do this please help me my code is given below
and i want to change it to ajax submit can you please help me
this is my login.php
session_start();
require_once 'class.user.php';
$user_login = new USER();
if($user_login->is_logged_in()!="")
{
$user_login->redirect('../mydrive/dashboard');
}
if(isset($_POST['btn-login']))
{
$email = trim($_POST['txtemail']);
$upass = trim($_POST['txtupass']);
if($user_login->login($email,$upass))
{
$user_login->redirect('../mydrive/dashboard');
}
}
?>
class.user.php function
public function login($email,$upass)
{
try
{
$stmt = $this->conn->prepare("SELECT * FROM users
WHERE email=:email_id");
$stmt->execute(array(":email_id"=>$email));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if($userRow['userStatus']=="Y")
{
$checkedupass =
$userRow['userPass'];
if(password_verify($upass,$checkedupass))
{
$_SESSION['userSession'] = $userRow['id'];
return true;
}
else
{
if user details are incorrect or not logged in or no account found:
header("Location: login?
error=invalid_login");
exit;
}
}
else
{
header("Location: login?
error=inactive");
exit;
}
}
else
{
header("Location: login?
error=AccountNotFound");
exit;
}
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
}