You are here: two levels of access login script « PHP Programming Language « IT news, forums, messages
two levels of access login script

Posted by jsd219 on 05/31/07 03:40

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
below:

<?php
// we must never forget to start the session
session_start();
$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');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
include 'closedb.php';
}
?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo
$errorMessage; ?></
font></strong></p>
<?php
}
?>
<form method="post" name="frmLogin" id="frmLogin" class="box">
<table width="400" border="1" align="center" cellpadding="2"
cellspacing="2">
<tr>
<td colspan="2"><b>Login</b></td>
</tr>
<tr>
<td width="150">User Id</td>
<td><input name="txtUserId" type="text" id="txtUserId" class="box"></
td>
</tr>
<tr>
<td width="150">Password</td>
<td><input name="txtPassword" type="password" id="txtPassword"
class="box"></td>
</tr>
<tr>
<td width="150">&nbsp;</td>
<td><input type="submit" name="btnLogin" value="Login" class="box"></
td>
</tr>
</table>
</form>
</body>
</html>

thank you in advanced

God bless
jason

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация