很奇怪,  不能登陆自动跳转:
 下面是登陆界面的代码 <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>密&nbsp; 码:</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

解决方案 »

  1.   

    确认 fun_goto("index.php"); 已被执行
    在执行此函数前,不能有任何输出
      

  2.   

    本帖最后由 xuzuning 于 2013-05-25 08:53:52 编辑
      

  3.   


    fun_goto("index.php"); 这函数确实是被执行了,我已经测试到是啥问题了...是session变量保存不了...不懂配置PHP.ini,现在在努力需找解决方法,可以给一下PHP.ini的文件我看看吗?
      

  4.   


    fun_goto("index.php"); 这函数确实是被执行了,我已经测试到是啥问题了...是session变量保存不了...不懂配置PHP.ini,现在在努力需找解决方法,可以给一下PHP.ini的文件我看看吗?
    只要我把index.php的验证权限给注释掉,就可以跳转了,
    以下是index.php的验证代码<?php 
    require_once('inc/config.php');
    require_once('inc/class.php'); 
    require_once('inc/function.php');
    //检查服务器连接 
    /*if ($_SESSION["user_id"]=="")
    {
    fun_goto("login.php");
    exit();

    require_once('inc/admin.php');*/
    ?>所以我猜是session 不能保存值,可是我找不到原因  T.T
      

  5.   

    之后我又做了一个测试session 是否传递了的测试页面...确实是session 不能传递  本页得到的_GET变量有:Array
    (
    )
    本页得到的_POST变量有:Array
    (
    )
    本页得到的_COOKIE变量有:Array
    (
        [PHPSESSID] => 9d0a7dc7a57db4017623ee1168e7015c
        [user_id] => 1
    )
    本页得到