Hello everybody I am trying to make a login script in PHP.. it works well i am able to login but i got this strange bug or whatever to call it... you see when i login as an ordinary user it works fine, but when i login as admin i get loged in but in the same time it says my login failed...
I got this welcome message:
<?php echo "<h3 id ='tjena'> Welcome ".$_SESSION['user']."</h3>";?>
so i know that i am actully logged in... However i also got a header which are supposed to lead me to ?success but of some reason it fails and directs me to ?error
Here is my code:
while($row = $result->fetch_object()) {
if($username == $row->username) {
$checkPassword = password_verify($password,$row->password);
if($checkPassword ){
session_start();
$_SESSION['loggedIn'] = true;
$_SESSION['user'] = $row->username;
$_SESSION['admin'] = $row->admin;
$_SESSION['LAST_ACTIVITY'] = time();
header("Location:index.php?success");
$fail = false;
}
} else {
$fail = true;
}
}
if($fail){
header("Location:index.php?error");
}
Does somebody know what is causing this error? Thans in advance!