entity's code should work except that the $i is in single quotes, which will not actually evaluate to '1', '2', or '3'.
To do it entity's way, try this:
for($i=1; $i<=3;$i++){
if (($cookie_security_level != $i ) or ($session_security_level != $i)) {
error_handle("3. You do not have enough security privilages to view this page!");
exit();
}
}
However, just to help you out a little more, the problem with your original if statement is that you can't compare one variable three times like that. If you wanted to do what you are trying to do, you would need to do this:
if (($cookie_security_level != '1' && $cookie_security_level != '2' && $cookie_security_level != '3') || ($session_security_level != '1' && $session_security_level != '2' && $session_security_level != '3'))
{
error_handle("3. You do not have enough security privilages to view this page!");
exit;
}
Notice that I changed the || to &&. There is also a lot more code than you originally put in! The reason is, PHP evaluted your original if() statement like this:
1) if $cookie_security_level does not equal '1', it evaluates to TRUE, which means the code is executed. If it is '1', it evaluates to FALSE, and the || makes it go to the next statement.
Here is where the problem is:
2) The second statement PHP evaluates is "if '2'". The problem here is that you didn't include the $cookie_security_level again. Unfortunately in PHP you can't just do if ($cookie_security_level != 1 || 2 || 3), because $cookie_security_level != 1 is evaluted before || 2 || 3.
I hope you are understanding what I am trying to say...
-Percy