two levels of access login script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a fairly simple login in script and I need to make it have two
levels of access not one. can anyone help me with this? The script is

// we must never forget to start the session
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
include 'config.php';
include 'opendb.php';
$userId = $_POST['txtUserId'];
$password = $_POST['txtPassword'];
// check if the user id and password combination exist in database
$sql = "SELECT user_id
FROM auth_user
WHERE user_id = '$userId'
AND user_password = '$password'";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) == 1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_in'] = true;
// after login we move to the main page
header('Location: list_pages.php');
} else {
$errorMessage = 'Sorry, wrong user id / password';
include 'closedb.php';
<meta http-equiv="Content-Type" content="text/html;
if ($errorMessage != '') {
<p align="center"><strong><font color="#990000"><?php echo
$errorMessage; ?></
<form method="post" name="frmLogin" id="frmLogin" class="box">
<table width="400" border="1" align="center" cellpadding="2"
<td colspan="2"><b>Login</b></td>
<td width="150">User Id</td>
<td><input name="txtUserId" type="text" id="txtUserId" class="box"></
<td width="150">Password</td>
<td><input name="txtPassword" type="password" id="txtPassword"
<td width="150">&nbsp;</td>
<td><input type="submit" name="btnLogin" value="Login" class="box"></

thank you in advanced

God bless

Re: two levels of access login script

Quoted text here. Click to load it

Actually a better way of putting it is, I have two hard coded user ids
and passwords with an aditional field called level. for the sake of
this explanation lets call them.
user_id - abc  password - 123  level - 1
user-id - xyz  password - 456  level - 2

I have two separate admin pages called list_pages.php and

I need a login to allow people that sign in with user_id abc to be
able to access list_pages.php and users that sign in with user_id xyz
to be able to access list_pages1.php

can anyone help, Please. i am quite a novice.

God bless

Site Timeline