Jump to content

If Statement Failing


fife

Recommended Posts

Ok I have a permission set in session. This permission can be 1,2,3. I have a page in which I echo the permission to make sure its correct. Currently when I view this page the permission is 1

 

at the top of the next page I have this

 


if($_SESION['per']!='1'){
$url = "/members/?permission=false";        
header("Location: $url"); 
}

 

for some reason the redirect is running when it shouldnt as the per is 1!! Not only that but I want to allow 2 to view this page too so the code would read...

 

 


if($_SESION['per']!='1' || $_SESION['per']!='2'){
$url = "/members/?permission=false";        
header("Location: $url"); 
}

 

but the first part isnt working so adding the other permission is pointless for now. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/270566-if-statement-failing/
Share on other sites

You have a spelling error in your session variable. It's - $_SESSION

 

Do you have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by reporting and displaying all the errors it detects. You will save a TON of time.

 

Your second test, with two conditions, would need to use an and comparison operator &&

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.