Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP: Displaying different menus to different user types.

  • 27-10-2010 05:45PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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