Jump to content

[SOLVED] If statement wrong


Asheeown

Recommended Posts

[code]
if(!$_SESSION['LoggedIn']) {
echo "<p><strong>Sorry you must be logged in to view this page.</strong></p>";
die();
} elseif($_SESSION['UserGroup'] > "1") {
echo "<p><strong>Sorry you have insufficient privileges to view this page, if you feel this information is incorrect please contact the administrator.</strong></p>";
die();
}[/code]

Now the LoggedIn Session part works, however when I am logged in it says my permissions are not sufficient which is incorrect I even "echoed" the session out right before the die command and it came up as 2
Link to comment
https://forums.phpfreaks.com/topic/36012-solved-if-statement-wrong/
Share on other sites

I made it into one so it's more efficient:

[code]
if(!$_SESSION['LoggedIn'] && $_SESSION['UserGroup'] > 1) {
echo "<p><strong>Sorry you have insufficient privileges to view this page, if you feel this information is incorrect please contact the administrator.</strong></p>";
die();
}[/code]

$_SESSION['LoggedIn'] = 1 and $_SESSION['UserGroup'] = 2
Now it just doesnt work
try this ok

[code]

<?php

if( (!$_SESSION['LoggedIn'] )&& (!$_SESSION['UserGroup'] > 1) ) {
echo "<p><strong>Sorry you have insufficient privileges to view this page, if you feel this information is incorrect please contact the administrator.</strong></p>";
die();
}

?>
[/code]
"when I am logged in it says my permissions are not sufficient which is incorrect I even "echoed" the session out right before the die command and it came up as 2"

2 > 1 - therefore, the code works fine. You just don't understand what > means.

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.