这段代码有什么问题...... ???它没有重定向到另一页但是留在login.php页面(空白页)......数据库都正确... 有人可以帮我这个代码...... 非常感谢你的帮助...
<?
require_once('include/config.php');
require_once('include/functions.php');
session_start();
session_destroy();
$message="";
$Login=$_POST['Login'];
if($Login){ // If clicked on Login button.
$username=$_POST['username'];
$md5_password=md5($_POST['password']); // Encrypt password with md5() function.
mysql_select_db("$db", $con);
$result=mysql_query("select * from staff where stf_username='$username' and stf_password='$md5_password'");
$sql =mysql_query("select stf_level from staff where stf_username='$username'");
if(mysql_num_rows($result)!='0'){ // If match.
session_register("username");
while($row = mysql_fetch_array($sql))
{
//echo $row['level'] . " ";
if($row['stf_level'] == 1){
header("location:admin/index.php");
}
elseif($row['stf_level'] == 2){
header("location:cashier/index.php");
}
elseif($row['stf_level'] == 3){
header("location:waiter/index.php");
}
elseif($row['stf_level'] == 4){
header("location:kitchen/index.php");
}
}
//header("location:main.php"); // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}
} // End Login authorize check.
?>
<!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=utf-8" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="description" content="Description" />
<meta name="keywords" content="Keywords" />
<meta name="author" content="Aafrin" />
<title>iCafe Login</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="css/keyboard.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/keyboard.js"></script>
</head>
<body>
<div id="wrapper">
<div id="loginPanel">
<img class="image" alt="" src="images/logo.png" width="220" height="120" />
<div id="error"><? echo $message; ?></div>
<form id="form" name="form" method="post" action="<? echo $PHP_SELF; ?>">
<label>Username :</label>
<input type="text" name="username" class="keyboardInput" />
<label>Password :</label>
<input type="password" name="password" class="keyboardInput" />
<input name="Login" type="submit" id="Login" value="Login" class="submit" />
<!--
<input type="submit" value="Submit" name="submit" class="submit" />
-->
</form>
<div id="footer">
XYZ © 2012 - All Rights Reserver | Powered By <a href="http://www.facebook.com/kesavans">Kesavan</a>
</div>
</div>
<!--
<div id="details">
<p>Login Details</p>
Admin : admin
<br />
Waiter : waiter
<br />
Kitchen : kitchen
<br />
Cashier : cash
</div>
-->
</body>
</html>
答案 0 :(得分:0)
我认为你应该在以下之后放置空间: 它会像
header("location: cashier/index.php");
答案 1 :(得分:0)
尝试@header("")
可能是您有错误。为什么不保存变量中的所有位置并将变量传递给头函数?
if($x=1){$loc="admin/index.php"}
if($x=2){$loc="staff/index.php"}
if($x=3){$loc="manager/index.php"}
@header('location:$loc')