Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Showing admin options for more than 1 user?

    Hi, on my site i have more that one admin, i was wondering how i would start the $admin for more than 1 user.

    This is how it works for just the 1 user:
    PHP Code:
    <?php

    if (@$_SESSION['loginname'] == 'SMgames')
    {
    $_SESSION['admin'] = 'true';}
    else{
    $_SESSION['admin'] = 'false';}

    if (
    $_SESSION['admin'] == 'true'){ ?>

    ADMIN OPTIONS HERE

    <?php ;} ?>
    I was thinking would something like this work:
    PHP Code:
    <?php

    if (@$_SESSION['loginname'] == 'SMgames')
    (@
    $_SESSION['loginname'] == 'Otheruser')
    {
    $_SESSION['admin'] = 'true';}
    else{
    $_SESSION['admin'] = 'false';}

    if (
    $_SESSION['admin'] == 'true'){ ?>

    ADMIN OPTIONS HERE

    <?php ;} ?>
    If you have any ideas thanks.
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Your second example won't work because the line after the first part of the if statement isn't inside the parentheses. You would need to use the or operator.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How could you help me?
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    You should give each user a permission level, and show the admin page if the user's permission is admin-level.

    if($_SESSION['user']['permission'] == 2)
    {
    //Show admin page
    }

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What woul;d i have to do, would i have to set each user i want to be an admin to permission 2, if so how?
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Add a column to the user table in your database, and use it to hold the permission level for each user. Then, when the user logs in, retrieve that column's value along with the username, etc.

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

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