Jump to content


Photo

Help w/conditional


  • Please log in to reply
2 replies to this topic

#1 ivalea

ivalea
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 28 February 2006 - 05:50 PM

Hi -
I'm sortof a newb when it comes to PHP and I'm trying to build a site that offers two account types. I also have pages that I want to restrict access to depending if they have an account type of 1 or 2.
I am having some trouble with the if statement that would not only check to see if the user is logged in, but logged in with a certain account type. This is what I have:

if(empty($_SESSION[user1]))
{
include_once("lerr.php");


}

My question is how to I get it to say if user is logged in AND account type = 1 then direct them to the page otherwise show the lerr.php page.

I hope I've explained this correctly. Any help would be greatly appreciated - I've spent way too much time on this one. :)

Thanks!

ivalea

#2 soccer022483

soccer022483
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 February 2006 - 06:37 PM

how about

if(isset($_SESSION['user1']) && $_SESSION[user1_account_type] == 1) {
     //page output
}
else {
     require_once 'lerr.php';
}

I'm assuming if user1 is logged in, you set $_SESSION[user1] equal to true or something, otherwise you don't set it to anything. I'm not sure if I answered you correctly or not.

#3 ivalea

ivalea
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 28 February 2006 - 11:06 PM

Thanks soccer for your reply... unfortunately this was what I thought to be the logical solution and tried it first but it didn't work. I finally did get it to work though by adding a separate if to the page directly. So the main access page just checks to see if they are logged in and then passes them onto the page and then checks to see what type of account they have. Maybe not the best solution, but it works! :)

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users