SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to create access control for menus in php

    Hi

    how to create access control menus in php. I want to create where all the menus will be there. when a user logged in to the application he should see only those menus which we give access and remaining menus should be hidden or disable



    Thanks

  2. #2
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In a table lets say user_type store these:
    user_id
    user_type

    u can start user_id from any number you want, lets say 1001 which means Super admin, 1002 Admin, 1003 user, 1004 and so on....
    user_type can be like admin, user etc from above.

    Fetch these values and store it in session and show different menu to different users. You might have to store the access level in db for the menu item if want it dynamically. OR can implement it in PHP code some thing like:
    PHP Code:
    if ($user_id == 1001) { //super admin can see all menus
     
    echo "this menu 1";
     echo 
    "this menu 2";
     echo 
    "this menu 3";
    }
    elseif (
    $user_id == 1002) { //admin can see 2nd level menu
     
    echo "this menu 2";
     echo 
    "this menu 3";
    }
    elseif (
    $user_id == 1003) { //user can see 3nd level menu
    echo "this menu 3";

    Just a basic idea to start with.

    Good luck!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •