Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP: Displaying different menus to different user types.

Options
  • 27-10-2010 5:45pm
    #1
    Registered Users Posts: 73 ✭✭


    Hi all,

    I'm new to PHP and just looking for any advice anyone might have on the following problem I'm having.

    I have created a database and tables for registering and logging in users. Each record has three different User Types (or roles): 1, 2 and 3. Once the session has started, I would like to make certain menu items available to certain User Types. I suppose it is some sort of if...elseif statement such as:

    <?php if($UserType==1) echo {"<p>Menu1</p>"}
    elseif($UserType==2) echo {"<p>Menu2</p>"}
    elseif($UserType==3) echo {"<p>Menu3</p>"}; ?>

    Would anybody be able to point me in the right direction? I'd really appreciate any help at all.


Comments

  • Registered Users Posts: 894 ✭✭✭Dale Parish


    Just use
    if(isset($_POST)) { echo "Some data"; }
    if(isset($_POST)) { echo "Some more data"; }

    Having said that checking it via POST might not be the best option but if it is for something basic then it's fine. You might be better off sending the info via session


  • Registered Users Posts: 73 ✭✭TunaSaladBB


    Thanks very much. Got it sorted anyway. Assigned session variables based on the users' access level stored in my database.


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    might be better to have menus in different files and just INCLUDE the file instead of echoing out the full code

    http://php.net/manual/en/function.include.php


Advertisement