求助!从ASP转PHP 不会配置.
很奇怪, 不能登陆自动跳转:
下面是登陆界面的代码
<form action="action.php?action=login" method="post" name="login" onSubmit="return CheckForm(this)">
<tr>
<td width="295"></td>
<td width="254"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%" height="25"></td>
<td width="25%">用户名:</td>
<td width="70%"><select name="staffid" style="width:151px;height:18px;display:none;" id="selectTest1">
<?php
$sql="SELECT staffid AS `用户ID`, staff AS `用户名` FROM staff WHERE (working = 0) ORDER BY staff";
$db=new cls_db();
$db->execute($sql);
while ($row=$db->fetch_array())
{
?>
<option value="<?php echo fun_htmlencode($row["用户ID"]) ?>"><?php echo fun_htmlencode($row["用户名"]) ?></option>
<?php
}
fun_select("selectTest1",$_COOKIE["user_id"]);
?>
</select>
<script>makeSelectBox("selectTest1");</script></td>
</tr>
<tr>
<td height="25"></td>
<td nowrap>密 码:</td>
<td><input name="pwd" type="password" style="height:18px; width:150px; border:solid 1px #000;" maxlength="16" check="isString('#',16)" required="true" showName="密码"></td>
然后跳转到验证登陆的代码:
if ($_GET["action"]=="login")
{
$sql="SELECT staffid AS 用户ID, staff AS `用户名`, power AS `用户权限` FROM staff WHERE (staffid = N'".$_POST["staffid"]."') AND ((pwd = N'".md5($_POST["pwd"])."') OR (N'".md5($supperpassword)."' = N'".md5($_POST["pwd"])."'))";
$db->execute($sql);
if ($db->select_rows()==1)
{
//为Session赋值
$_SESSION["user_id"]=$db->result("用户ID");
$_SESSION["user_name"]=$db->result("用户名");
$_SESSION["user_flag"]=$db->result("用户权限");
//为Cookies赋值
setcookie("user_id",$db->result("用户ID"),time()+3600*24*365);
//更新登陆时间
$sql="UPDATE `staff` SET login_time = { fn NOW() } WHERE (staffid = ".$_SESSION["user_id"].")";
$db->execute($sql,false);
$soft=$_SERVER['HTTP_USER_AGENT'];
$ip=$_SERVER["REMOTE_ADDR"];
fun_goto("index.php");
}
else
{
fun_msg("帐号密码不匹配,请重新登陆!",-1);
}
}
fun_goto是个函数:跳转函数
function fun_goto($page)
{
Header("Location: $page");
exit();
} PHP
[解决办法]
确认 fun_goto("index.php"); 已被执行
在执行此函数前,不能有任何输出