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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.