Jump to content

[SOLVED] or in an if statment


Comdemned

Recommended Posts

Hi,

 

Is there anyway to have a or in an if statment

eg

<?php
if (!$_SESSION['perm'] = 1 or 2){
die("you shouldnt be here");
}
?>

 

or do you have to so it like

 

<?php
if (!$_SESSION['perm'] = 1){
if (!$_SESSION['perm'] = 2){
die("you shouldnt be here");
}
}
?>

also when doing it this way is there any way to stop the if statment from setting $_SESSION['perm'] = 2 as it is and its messing with my authentication.

 

Ive searched the forums lots but its kind of hard to search for "or" as it shows up so often.

 

Thanks in advance

Murray

 

Link to comment
https://forums.phpfreaks.com/topic/84844-solved-or-in-an-if-statment/
Share on other sites

Thank you that has solved both problems,

I thought the || in an if statment ment AND not OR.

Also i noticed you used == instead of =, which has fixed the problem of the if statment setting $_SESSION['perm'] =2,

what exactly does == mean compared to = other that it will not update the variable?

 

Murray

 

PS sorry didnt see that link at the bottem.

thanks again

 

Murray

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.