Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6092947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:30:13+00:00 2026-05-23T12:30:13+00:00

I wanted some suggestions from someone with experience in php. I am making a

  • 0

I wanted some suggestions from someone with experience in php.

I am making a website in php which will have 4 kinds of users :
1. guest(unregistered),
2. registered,
3. registered with special privilages,
4. admins

So the same page will be visible differently to all four of them.

Right now I am doing that by using if conditions.
In every page, I am checking the role of the user and then using many if statements to display the page accordingly.

It makes the code very big and untidy and I have to check conditions again and again in all the pages.

  1. Is there a better way to do this?

  2. How is this done in big professional websites?

  3. Extended Question:
    What is the most optimal way to do the same using a MVC framework like kohana 3.1? Does it have anything to do with acl?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:30:14+00:00Added an answer on May 23, 2026 at 12:30 pm

    It really depends on what you need.

    For example if the page has big part that change completely, what I would suggest is to create different templates and include them depending on their “permissions”

     $permission = $_SESSION['type_user'];
     include '/path/to/file/with/permission/'.$permission.'/tpl.html';
    

    and have something in the page similar to

    <?php
    //inside include.php you have the line similar to
    //$permission = isset($_SESSION['type_user']) && $_SESSION['type_user']!=''?$_SESSION['type_user']:'common';
    require_once '/mast/config/include.php';
    include '/path/to/file/with/permission/common/header.html';
    include '/path/to/file/with/permission/'.$permission.'/tpl_1.html';
    include '/path/to/file/with/permission/common/tpl_2.html';
    include '/path/to/file/with/permission/'.$permission.'/tpl_3.html';
    include '/path/to/file/with/permission/common/footer.html';
    ?>
    

    if the script is full of small parts like “show this text”, or “show this button”, you can create a function that will check the permissions for you

    <?php
    function can_user($action, $what){
       switch($action){
          case 'write':
              return $your_current_if_on_what;
              break;
          case 'read':
          default:
              return $your_current_if_on_what;
              break;
       }
    }
    ?>
    
    and the template will look like:
    
    [my html]
    <?=can_user('read','button')?'My Button':''?>
    [my html]
    

    As a rule of thumb, if a piece of code is used more than 2 times, it needs to be put in a function/file separately, so if you have many “IFS” you need to create a function

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanted some opinions from people that have run Selenium ( http://selenium.openqa.org )
I would like to learn ASP.NET and just wanted some input as to which
I'm about to port a smallish library from Java to Python and wanted some
I have an app where I need to prevent users from editing data while
Okay, thus may seen kind of odd, but I wanted to get some suggestions
Wanted some ideas about building a tool which can scan text sentences (written in
I wanted some of those spiffy rounded corners for a web project that I'm
I know the topic I started is too subjective. But I just wanted some
Wanted to get some consensus around a UI feature I'm working on right now.
I wanted to set some handler for all the unexpected exceptions that I might

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.