admin user permission

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • motif
    New Member
    • Dec 2007
    • 3

    #1

    admin user permission

    hi
    i am new to php and mysql i am devloping a site wich required diffrent user level in admin area, basically i want to assign diffrent role for diffrent user like some user can update the records, some user can delete the record and superadmin will have all the access and could create the user too.

    i search the google and found some basic idea however its not yet clear how to use user group and user permissions database, will you plz help me out i am using php and mysql i appriciate if some one explain me from the beginning

    thanks
  • djpaul
    New Member
    • Oct 2006
    • 137

    #2
    Hee motif,
    I did almost the same with my website.
    I created an table admin with ID, username, password, email, admin.
    Where admin is like 1, 2, and 3.
    Then is set the session variables like:

    [PHP]$query = mysql_query "SELECT * FROM admin WHERE username='user' AND password='passw ord' LIMIT 1";

    $admin = mysql_fetch_arr ay($query);
    session_start() ;
    //set session variables
    $_session['user'] = $admin['username'];
    $_session['password'] = $admin['password'];
    $_session['admin'] = $admin['admin'];
    [/PHP]

    Then you can do some compares in your script like:
    [PHP]
    if ($_session['admin'] == 2){
    //blalblalbla
    }else{
    //bliebliebliep
    }[/PHP]

    Maybe this will help you.

    Gr Paul

    Comment

    • motif
      New Member
      • Dec 2007
      • 3

      #3
      thank you very much for your advices but i still have some confusion what u mean by following

      "" Then you can do some compares in your script like:
      [PHP]
      if ($session['admin'] == 2){
      //blalblalbla
      }else{
      //bliebliebliep
      }[/PHP]

      ""

      do i need to check condition on every page and every role(admin)?? if
      if ($session['admin'] == 2){
      //show edit button
      }else{
      //view button
      }[/PHP]

      so other idea trick can also work??

      regards

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by motif
        thank you very much for your advices but i still have some confusion what u mean by following

        "" Then you can do some compares in your script like:
        [PHP]
        if ($session['admin'] == 2){
        //blalblalbla
        }else{
        //bliebliebliep
        }[/PHP]

        ""

        do i need to check condition on every page and every role(admin)?? if
        if ($session['admin'] == 2){
        //show edit button
        }else{
        //view button
        }[/PHP]

        so other idea trick can also work??

        regards
        do i need to check condition on every page and every role(admin)??
        Yes. It's simple - just do it on all pages that you need to check for.

        Comment

        Working...