i) 具有如下领域的我的图表:
id username password role
行政具有第1号的作用,正常用户的作用是第2号
<?php
// we must never forget to start the session
session_start();
$errorMessage = ;
if (isset($_POST[ username ]) && isset($_POST[ password ])) {
include library/connect.php ;
$username = $_POST[ username ];
$password = $_POST[ password ];
// check if the user id and password combination exist in database
$sql = "SELECT role FROM user WHERE username = $username AND password = $password ";
$result = mysql_query($sql) or die( Query failed. . mysql_error());
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 1 AND $row[ role ]==2) {
// the user id and password match,
// set the session
$_SESSION[ userame ] = true;
// after login we move to the main page
header( Location: login_success.php );
exit;
}
elseif (mysql_num_rows($result) == 1 AND $row[ role ]== 1) {
// the user id and password match,
// set the session
$_SESSION[ admin ] = true;
$_SESSION[ username ] = true;
// after login we move to the main page
header( Location: admin.php );
exit;
}
else {
$errorMessage = Sorry, wrong user id / password <a href="login.html">Go Back</a> ;
}
include library/closedb.php ;
}
?>
<?php
if ($errorMessage != ) {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
当一个行政记录中,它进行罚款,转而管理。 php 而当一个正常用户记录完全没有发生时,该页就刚刚恢复。 什么是错了?