Jump to content

checking 2 arguments


denoteone

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/94488-checking-2-arguments/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/94488-checking-2-arguments/#findComment-483867
Share on other sites

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.