Asheeown Posted January 28, 2007 Share Posted January 28, 2007 [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 Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 Actually I figured out what it is but not a solution. It's the elseif, I reversed them and it says I'm not logged in. Quote Link to comment Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 Hmmmmm. Try setting the type of the session variable. e.g.[code]settype($_SESSION['UserGroup'], "float");[/code]I don't think you need quotes around the 1 either. Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 I use [quote]$_SESSION['UserGroup'] > "1"[/quote]On my homepage to determine to show the Admin Section button or not so i know its right Quote Link to comment Share on other sites More sharing options...
fert Posted January 28, 2007 Share Posted January 28, 2007 well with [code]$_SESSION['UserGroup'] > "1"[/code]That's saying if the value of $_SESSION['UserGroup'] is greater than the ascii value of 1 which I believe is 49 Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 I'm talking about in the IF statement...I know this If statement works just in parts why not together? Quote Link to comment Share on other sites More sharing options...
fert Posted January 28, 2007 Share Posted January 28, 2007 And that's what I'm talk about change "1" to 1 Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 Look I know that way doesn't work thats what I've been saying, and anyway I'm using the if statement[code]if($_SESSION['UserGroup'] > "1")[/code]On a different page and it works fine Quote Link to comment Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 It's bad coding practice. You should change that too. Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 I'm not changing anything it works fine, I'm just trying to figure out why my first IF statement doesn't work Quote Link to comment Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 Try empty rather than !i.e (!empty($variable)) { Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 Read what the question asks...$_SESSION['UserGroup'] needs to be greater than "1" or else it dies...not empty the first part(the logged in part) works fine Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 Any idea why this would work anywhere else and not inside a function when the $_SESSION['UserGroup'] is set and it is greater than 1 Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 Integers can not be surrounded in quotes.[code=php:0]} elseif($_SESSION['UserGroup'] > 1) {[/code] Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 i already tried that Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 Post your current code then, I don't see any problem. Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 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'] = 2Now it just doesnt work Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 28, 2007 Share Posted January 28, 2007 try this ok[code]<?phpif( (!$_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] Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 [code=php:0]if ((!$_SESSION['LoggedIn']) || (!$_SESSION['UserGroup'] > 1) ) {[/code] Quote Link to comment Share on other sites More sharing options...
Asheeown Posted January 28, 2007 Author Share Posted January 28, 2007 Perfect Thorpe I didn't think to use || I used && and it said I was logged in everytime but it works perfect now, thanks Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 28, 2007 Share Posted January 28, 2007 thorpe dosent the || mean or and this means and &&cheers. Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 [quote author=redarrow link=topic=124359.msg515199#msg515199 date=1169957194]thorpe dosent the || mean or and this means and &&cheers.[/quote]Exactly. Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 28, 2007 Share Posted January 28, 2007 cheers m8 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 28, 2007 Share Posted January 28, 2007 "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. Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 28, 2007 Share Posted January 28, 2007 more then >less then < Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.