Assigning Roles to Users

Discussion in 'PHP' started by newlearn, May 24, 2007.

  1. #1
    I need some guidance about assigning roles to different users of an Application.
    There are three levels. Managers, Employees and Users.

    When users login, how will I make sure that not all access is gven to them in the application.

    Are there any tutorials that can give me little idea about how to do this?
     
    newlearn, May 24, 2007 IP
  2. tinkerbox

    tinkerbox Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When login assign value to each of them using session.
    Eg:
    
    
    if ($login_ok) {
    
    session_start();
    if ($login_as == "manager") {
      $_SESSION['level'] = '1';
    } else if ($login_as == "employee") {
      $_SESSION['level'] = '2';
    } else if ($login_as == "user") {
      $_SESSION['level'] = '3';
    }
    
    }
    
    PHP:
    Page for each level can access/see differently:
    
    session_start();
    if ($_SESSION['level'] == '1') {
      // show to manager
    } 
    
    PHP:
    Hope you'll get some idea how to do it :)
     
    tinkerbox, May 24, 2007 IP
  3. newlearn

    newlearn Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thankyou so much. I will try to see how I can get things work with this.
     
    newlearn, May 24, 2007 IP
  4. tinkerbox

    tinkerbox Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    post update here.
    always happy to help :D
     
    tinkerbox, May 24, 2007 IP
  5. newlearn

    newlearn Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I have couple of more doubts .

    When I check for userLevels during login, should I have separate pages for different levels.

    Like - showTable.php will have 3 copies -

    showTableManager.php , showTableAdmin.php, showtableEmp.php

    Other way, I was thinking to go with if conditions for the data to be displayed or hidden on the same file showTable.php .
     
    newlearn, Jun 18, 2007 IP
  6. newlearn

    newlearn Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Somebody please reply.
     
    newlearn, Jun 19, 2007 IP