Solved

What is the most practical way to display items based in each user level?

Posted on 2016-09-15
3
43 Views
Last Modified: 2016-09-16
Hello,

I'm trying to figure out how to build a menu that will show more or less elements based on each user level in PHP.

I'm currently naming user levels in the DB as "Admin", "User", "Special" and so on. What I need is for the Admin to see all elements, the user to see some elements and so on. I could do lots of IF statements but maybe there's a quick way to do it in a function or something?

Thanks in advance!
0
Comment
Question by:Caracena
3 Comments
 
LVL 30

Accepted Solution

by:
Marco Gasi earned 500 total points
Comment Utility
An alternative to creating a menu with many if statements is to create 3 menus in 3 separate files, let's say menu_admin.php, menu_user.php and menu_special.php, then include the right file depending on the logged user level.
0
 
LVL 6

Author Closing Comment

by:Caracena
Comment Utility
Didn't thought it would make much sense but now that I read your response it totally made sense!
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Usually menu systems like this are created dynamically. You have a data structure in which the menu items and user access are stored which is used to construct the menu - the data structure is usually (but does not have to be) sourced from a database query that joins available menu items to users based on an access_rights table linking users to menu items.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now