Jump to content

[SOLVED] simple multiple if not statement error


jesushax

Recommended Posts

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

[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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.