0

So i have one global user home page after login, and an admin one.

admin page:

}
// select loggedin users detail
$res=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
if( $userRow['userEmail'] != "email@example.com"){
header("Location: home.php");
exit;
}

normal one:

// select loggedin users detail
$res=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
if( $userRow['userEmail'] = "adminemail"){
header("Location: admin.php");
exit;
}

why does it gives me a toomanyredirects error when i login with the normal user

Jonathan Kuhn
  • 15,279
  • 3
  • 32
  • 43
wiki wiki
  • 27
  • 4

1 Answers1

2

You have a typo in if statement ('=' instead of '=='), so the normal.php page is redirected to the admin and the admin.php is redirected back = redirect loop.

Correct this:

if ($userRow['userEmail'] == "adminemail") ....
Jan Rydrych
  • 2,188
  • 2
  • 13
  • 18
  • You should probably be more clear with what the issue is as it technically isn't an "error" (as no error would be thrown). The issue has to do with one equals sign will assign the value instead of compare it meaning the if statement will always be true. – Jonathan Kuhn Feb 06 '17 at 18:17