Results 1 to 3 of 3

Thread: Users level

  1. #1
    Private First Class
    Join Date
    Dec 2012
    Posts
    127
    Thanks
    132
    Thanked 114 Times in 63 Posts

    Users level in database

    Hey,

    I've got a problem with my PHP script - Admin Panel.
    Code looks fine but there is a notice about: Undefined variable: users_level
    I'm not sure but I've pointed mysql_query where the table and users_level is...

    Just want to make text like: You are logged in as: Jeplaa [Admin]


    The table in phpMyAdmin looks that:

    id name
    1 Admin
    2 Member



    Here's a code:

    PHP Code:
    <?php

        $connect 
    mysql_connect("localhost""root""");
        
    mysql_select_db("phplogin");

        
    $query_level mysql_query("SELECT name FROM users_level WHERE id = '$users_level'");
        
    $run_level mysql_fetch_array($query_level);
        
    $level_name $run_level['name'];
        
        
    $username $_SESSION['username'];

    ?>

    <html>
        <head>
            <title>Admin Panel</title>
        </head>
            <body>
                <h3>Admin Panel</h3>
                    
                <p>You are logged in as: <b><?php echo $username ?></b> [<?php echo $level_name ?>]</p>
            </body>
    </html>
    Please point me how to fix it.

    Thanks and regards in advance,
    Jeplaa
    Last edited by Jeplaa; 8th March 2013 at 15:54.

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    There was a time you could access the Request-variables without any additional code, but now you need to write:

    PHP Code:
    $users_level int($_GET["users_level"]); 
    or:

    PHP Code:
    $users_level int($_REQUEST["users_level"]); // this also takes _POST 
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    Jeplaa (8th March 2013)

  4. #3
    Private First Class
    Join Date
    Dec 2012
    Posts
    127
    Thanks
    132
    Thanked 114 Times in 63 Posts
    Ok, solved thanks for help kung foo man.

Posting Permissions

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