PDA

View Full Version : Users level



Jeplaa
8th March 2013, 15:32
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

$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

kung foo man
8th March 2013, 18:07
There was a time you could access the Request-variables without any additional code, but now you need to write:


$users_level = int($_GET["users_level"]);

or:


$users_level = int($_REQUEST["users_level"]); // this also takes _POST

Jeplaa
8th March 2013, 18:17
Ok, solved thanks for help kung foo man.