我已经在我的网站上创建了一个登录页面。这应该将用户重定向到index.php并隐藏登录和注册页面。但这就是我得到的;
“页面无法正确重定向
Firefox已检测到服务器正在以永远无法完成的方式重定向对此地址的请求。
This problem can sometimes be caused by disabling or refusing to accept cookies."
但是我没有在页面上设置任何cookie。
登录脚本如下:
<?php
if(isset($_POST['login-submit'])){
include 'dbh.inc.php';
$mailuid = $_POST['mailuid'];
$password = $_POST['login-password'];
if(empty($mailuid)){
header("Location: ../login.php?error=emptymailuid");
exit();
}
if(empty($password)){
header("Location: ../login.php?error=pwdempty");
exit();
}
$sql = "SELECT * FROM users WHERE usersEmail=? OR usersUsername=?";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
header("Location: ../login.php?error=sqlError");
exit();
}else{
mysqli_stmt_bind_param($stmt,"ss",$mailuid,$mailuid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0){
if($row = mysqli_fetch_assoc($result)){
$isActive = $row['usersActive'];
if($isActive == "Yes"){
$passwordCheck = password_verify($password,$row['usersPassword']);
if($passwordCheck == false){
header("Location: ../login.php?error=wrongpwd");
exit();
}else if($passwordCheck == true){
session_start();
$_SESSION['id'] = $row['usersID'];
$_SESSION['userId'] = $row['usersUsername'];
$_SESSION['email'] = $row['usersEmail'];
header("Location: ../index.php");
exit();
}
}else{
header("Location: ../login.php?error=notActive");
}
}
}else{
header("Location: ../login.php?error=noUser");
exit();
}
}
}else{
header("Location: ../login.php");
exit();
}