我有一个登录表单,其中检查用户的状态是否正确,然后应将其定向到主页,否则应将其定向到注册页面。
我已经写了一个代码,但是它总是直接指向主页。
// Get Variables From The Form By Their Name Attributes
$username = $_POST['emailOrMobile'];
// Check if the user exist in database
$stmt = $con->prepare("select ID,firstName,email,mobile,password,status,token from users where email=? or mobile =?");
$stmt->execute(array($username,$username));
$info=$stmt->fetch();
if(password_verify($_POST['password'],$info["password"]))
{
//echo $info["status"];
if($info["status"]==1)
{
$_SESSION['ID'] = $info["ID"];
$_SESSION['USERNAME'] = $info["firstName"];
header('Location:home.php');
exit();
}
else
{
$_SESSION['ID'] = $info["ID"];
$_SESSION['USERNAME'] = $info["firstName"];
$_SESSION['mobile'] = $info["mobile"];
$_SESSION['token'] = $info["token"];
header('Location:register.php');
exit();
}
}
else
{
header('Location:errors.php');
exit();
}