Hi All,

I am creating an admin panel for a client, and part of the panel uses a menu system that, depending on the logged-in user's authorization level, displays certain menu items.

Here is the code that I have on the login form, called index.php

<?php require_once('Connections/verspeeten.php'); ?>
<?php
mysql_select_db($database_verspeeten, $verspeeten);
$query_rs_authlevel = "SELECT tbl_users.id_authlevel FROM tbl_users";
$rs_authlevel = mysql_query($query_rs_authlevel, $verspeeten) or die(mysql_error());
$row_rs_authlevel = mysql_fetch_assoc($rs_authlevel);
$totalRows_rs_authlevel = mysql_num_rows($rs_authlevel);
?>
<?php
// *** Register the variable named id_authlevel
session_start();
session_register("id_authlevel");
$id_authlevel = "id_authlevel";


$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $GLOBALS['PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "mainframe.php";
  $MM_redirectLoginFailed = "loginscripts/error.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_verspeeten, $verspeeten);

$LoginRS__query=sprintf("SELECT username, password FROM tbl_users WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));


$LoginRS = mysql_query($LoginRS__query, $verspeeten) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";


if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.:. Verspeeten Computer Systems - Help Desk Login .:.</title>
<link href="assets/css/verspeeten.css" rel="stylesheet" media="all" />
<style type="text/css">
@import url("assets/css/verspeeten.css");
</style>
</head>


<body>
<div id="login">
<p class="header">.:. please login .:.</p>
<form ACTION="<?php echo $loginFormAction; ?>" name="helpdesklogin" id="helpdesklogin" method="POST">
<p>
<input name="username" type="text" id="username" accesskey="u" tabindex="1" title="Please enter your usename here. (Alt+U)" value="username" size="7" maxlength="8" />
<br />
<input name="password" type="password" id="password" accesskey="p" tabindex="2" title="Please enter your password here. (Alt+P)" value="password" size="7" maxlength="8" />
<br />
<input type="submit" name="Submit" value="login" accesskey="s" tabindex="3" title="Login (Alt+S)" />
</p>
<p class="footer">Lost username/password?</p>
</form>
<p class="footer">VCS HelpDesk v.1</p>
</div>


</body>
</html>
<?php
mysql_free_result($rs_authlevel);
?>

Here is the code that I have on the main page, which is what they will see once they have logged in, this page is called mainframe.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.:. Verspeeten Computer Systems - Help Desk Mainframe .:.</title>
</head>


<body>

<?php
if ($id_authlevel == 1) {
   echo "admin";
} elseif ($id_authlevel == 2) {
   echo "manager";
} elseif ($id_authlevel == 3) {
   echo "tech";
}
?>
</body>
</html>

The issue that I am facing right now, is that whenever I try to login, it spits back this error:

Notice: Undefined variable: id_authlevel in c:\inetpub\wwwroot\verspeetensystems\mainframe.php on line 11

Notice: Undefined variable: id_authlevel in c:\inetpub\wwwroot\verspeetensystems\mainframe.php on line 13

Notice: Undefined variable: id_authlevel in c:\inetpub\wwwroot\verspeetensystems\mainframe.php on line 15


I was wondering if any of you would be able to shed some light on why this is happening. It's making me absolutely bonkers. I've looked at the PHP site for clues, but I can't seem to figure it out.


If you have any ideas, let me know. I'd be glad to hear them.

Sincerely,

Justin Kozuch

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to