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

Thread: Show if admin=1

  1. #1
    New Coder
    Join Date
    Apr 2010
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Show if admin=1

    Hello. I'm coding a usersystem. And now I want a navigator witch only administators can see. If you are an administator admin=1 in PHPmyAdmin you will be able to see the links.

    Any idea how I can do this?

  • #2
    New Coder
    Join Date
    Nov 2010
    Location
    United Kingdom
    Posts
    31
    Thanks
    0
    Thanked 9 Times in 8 Posts
    PHP Code:
    if ($admin==1){ echo "blablabla";} 

  • #3
    New Coder
    Join Date
    Apr 2010
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tropane View Post
    PHP Code:
    if ($admin==1){ echo "blablabla";} 
    Thanks. But I have a login system, and I'm having a box only admins should be able to see, so that's what I'm trying to do.

    This is my code so far:
    PHP Code:
    <?php 
    $admin 
    mysql_query("SELECT admin FROM post WHERE id='$logOptions_id' LIMIT 1");
    if (isset(
    $_SESSION['idx'])) { 
    if (
    $admin==1){ echo '<div id="title_orange">Staff tools</div>
    blablabla'
    ;};
    }
    ?>

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    if ($admin==1)
    You need to fetch the value from the mysql result set using mysql_fetch_row() or related.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I've seen cookie systems in which the user has a user level.. Example 1 member 2 admin etc... So you could setup a database with Name, password, userlevel and have php grab the data using a cookie for the session.

    Then, in the case you have that.. it would be like
    if ($userlevel == "2"){?>blah Coding<?}?>

  • #6
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    As abduraooft mentioned, you need to fetch the result of the query:

    Code:
    if (mysql_result($admin, 0))


  •  

    Posting Permissions

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