denoteone Posted March 5, 2008 Share Posted March 5, 2008 I want to hide a section of a page if a certain user is not logged in. I have a basic login page that sets a session to user. my main page looks something like this <?PHP session_start(); if(isset($_SESSION['user'])) { ?> <html>content</html> <?PHP }else{ redirect to login because they are not logged in. } ?> at this point I need to see if the session is set to user or admin so I guess something like <?PHP session_start(); if(isset($_SESSION['user'] or $_SESSION['admin'])); //this is were I am having trouble. { ?> <html>everyone sees this content <?PHP if (isset($_SESSION['admin'])); { ?> content only only admin sees </html> <?PHP }else{ ?> </html> <?PHP }elses{ redirect to login besause neither admin or user is set in the session this would let them both view the page and then at the bottom were the extra content for the admin would be I could have another if statement that checks to see if the session is set to admin if not I would just end my html page? what is the syntax to check two arguments and does it look like I am on the right path with this? Quote Link to comment Share on other sites More sharing options...
AV1611 Posted March 5, 2008 Share Posted March 5, 2008 If I understand, you have 3 types of logins: 1. Admin 2. Users 3. A Specific User using if isset for session admin or user is ok, then a subclause under session users like && $_SESSION['user'] == fred (which you would set when fred logged in) would give you the extra functionality. Please forgive me if I misunderstand the question. I just wrote the exact script last night for another project LOL. Quote Link to comment Share on other sites More sharing options...
AV1611 Posted March 5, 2008 Share Posted March 5, 2008 OH, and you have two ELSE in your clause... you can only have one. You need IF{ } ELSEIF{ } ELSE{ } Quote Link to comment Share on other sites More sharing options...
revraz Posted March 5, 2008 Share Posted March 5, 2008 if(isset($_SESSION['user']) || isset($_SESSION['admin'])); Try that Quote Link to comment Share on other sites More sharing options...
denoteone Posted March 5, 2008 Author Share Posted March 5, 2008 actually there are only 2 logins user and admin 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.