Hello,
I need some help from experts. I am testing a site I have created. I have an issue with login system. It worked fine using XAMPP on my computer but when I uploaded to a live server, login has been a problem.
This is what I get when I try to login.
"The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies."
The login script is below
<?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'];
$location = "Location: ../index.php";
header($location);
exit();
}
}else{
header("Location: ../login.php?error=notActive");
}
}
}else{
header("Location: ../login.php?error=noUser");
exit();
}
}
}else{
header("Location: ../login.php");
exit();
}
?>
Thanks guys