jesushax Posted September 30, 2008 Share Posted September 30, 2008 hi below is my code <?php if ($_SESSION["UserLevel"] != "Editor" || $_SESSION["UserLevel"] != "Admin"){ header("Location: /admin/admin.php?action=editorlevel"); } ?> my UserLevel is Admin and it keeps redirecting me it shouldnt be redirecting me, can anyone tell me if therse an error in the statement? Cheers Link to comment https://forums.phpfreaks.com/topic/126412-solved-simple-multiple-if-not-statement-error/ Share on other sites More sharing options...
GingerRobot Posted September 30, 2008 Share Posted September 30, 2008 That should be an and statement, not or - you cant be both an editor and admin so it it'll always be false. Dont forget the comparison will be case sensitive too. Link to comment https://forums.phpfreaks.com/topic/126412-solved-simple-multiple-if-not-statement-error/#findComment-653672 Share on other sites More sharing options...
Jibberish Posted September 30, 2008 Share Posted September 30, 2008 [code <?php ]if ($_SESSION["UserLevel"] != "Editor" || $_SESSION["UserLevel"] != "Admin"){ header("Location: /admin/admin.php?action=editorlevel"); } ?> its because you are using OR, it sees that your level is not an editor and the if statement results as true, and in turn running the code in its body, use && instead of || so it reads if your level isn't editor AND its not an ADMIN, then redirect them Link to comment https://forums.phpfreaks.com/topic/126412-solved-simple-multiple-if-not-statement-error/#findComment-653675 Share on other sites More sharing options...
jesushax Posted September 30, 2008 Author Share Posted September 30, 2008 ah right i get it now thanks alot Link to comment https://forums.phpfreaks.com/topic/126412-solved-simple-multiple-if-not-statement-error/#findComment-653679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.