我想将此简单的投稿表格转换为ajax投稿表格
我尝试执行此操作,但无法执行此操作,请帮助我,下面给出了我的代码
我想将其更改为ajax提交,请您帮我
这是我的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函数
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
{
如果用户详细信息不正确或未登录或找不到帐户:
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();
}
}