Jump to content

Help w/conditional


ivalea

Recommended Posts

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
Link to comment
Share on other sites

how about

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

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.
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.