不是很清楚。点A.php,跳到login.php,在本机登陆后正常跳到A.PHP,但在虚拟主机里登录后跳到index.php了。

解决方案 »

  1.   

    你的$_SERVER['REQUEST_URI']估计不可用,服务器估计不支持这种获取方式
    尝试$_SERVER["PHP_SELF"]
      

  2.   


    还是不行~~~~再附上login_form.php的代码:
    <!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" />
    <title>51Cover 专辑封面网 - 用户登录</title>
    <link href="style/default/reg.css" rel="stylesheet" type="text/css" media="all" />
    <script type="text/javascript" src="reg.js"></script>
    </head><body <?php if(isset($_GET['mail'])){?>onload="document.login.pwd.focus()"<?php }else{?>onload="document.login.mail.focus()"<?php }?>>
    <div id="container">
    <div id="top">
    <h1><a href="./"><img src="images/logo_small.gif" alt="LOGO" /></a></h1>
    </div>
    <div id="content">
    <fieldset>
    <legend>用户登录</legend>
    <form id="login" name="login" method="post" action="login.php?action=login">
    <ul>
    <li>
         <ul>
             <li class="a1">E-mail:</li>
                <li class="a2"><input name="mail" id="mail" value="<?php echo $_GET['mail'];?>" type="text" class="input" onmouseover="this.style.borderColor='#9ecc00'" onmouseout="this.style.borderColor='#84a1bd'" maxlength="255" /></li>
                <li class="a3" id="mail_info"><span class="ts">请用您在本站注册的E-mail登录。</span></li>
            </ul>
        </li>
    <li>
         <ul>
             <li class="a1">密码:</li>
                <li class="a2"><input name="pwd" id="pwd" type="password" class="input input2" onmouseover="this.style.borderColor='#9ecc00'" onmouseout="this.style.borderColor='#84a1bd'" maxlength="18" /></li>
                <li class="a3" id="pwd_info"><span class="ts">请输入密码。</span></li>
            </ul>
        </li>
    </ul>
    <div id="button">
    <input type="submit" name="" value=" 登 录 " class="button1" onmouseover="this.style.borderColor='#9ecc00'" onmouseout="this.style.borderColor='#84a1bd'" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" name="log2" value=" 注 册 " onclick="location.href='reg.php'" class="button1 button2" onmouseover="this.style.borderColor='#9ecc00'" onmouseout="this.style.borderColor='#84a1bd'" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" name="log2" value="返回首页" onclick="location.href='./'" class="button1 button2" onmouseover="this.style.borderColor='#9ecc00'" onmouseout="this.style.borderColor='#84a1bd'" />
        </div>
    </form>
    </fieldset>
    </div>
    <br clear="all" /><?php include("include/foot.php"); ?>
    </div>
    </body>
    </html>
      

  3.   

    IIS? 打印下$_SERVER就全明白了
      

  4.   

    foreach ($_SERVER as $k=>$v)
    {
       printf($k.":".$v."<br />");
    }
      

  5.   

    <?php
    header("content-type:text/html; charset=utf-8");
    include_once("./include/functions.php");
    include_once("config.php");
    foreach ($_SERVER as $k=>$v) 

      print($k.":".$v." <br />"); 
    if($_GET['action'] == 'login')
    {
     $mail = $_POST['mail'];
     $pwd = $_POST['pwd'];
     if($mail == "")
        {
            die("<script>alert(\"E-mail不能为空!\"); history.back();</script>");
        }
        else if(!eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$mail))
        {
            die("<script>alert(\"E-mail格式不正确!\"); history.back();</script>");
        }
        if($pwd == "")
        {
            die("<script>alert(\"密码不能为空!\"); history.back();</script>");
        }
        else if(strlen($pwd)<6)
        {
            die("<script>alert(\"密码应该为6~18位!\"); history.back();</script>");        
        }
        $mail2 = GetSQLString($mail,text);
        $pwd = md5($pwd);
        $pwd = GetSQLString($pwd,text);
        $sql = "SELECT * FROM `user` WHERE `mail` = $mail2 AND `pwd` = $pwd";
        mysql_query("SET NAMES UTF8");
        $result = mysql_query($sql,$conn);
        $row = @mysql_fetch_array($result);
        if($row[0]!="")
        {
            setcookie(userid,$row[id],time()+3600);
            setcookie(userpwd,$row[pwd],time()+3600);
            if($_COOKIE['lasturl']=="")
            {
                header("location:index.php");
                exit;
            }
            else
            {
                $lasturl = $_COOKIE['lasturl'];
                setcookie("lasturl","");
                header("location:$lasturl");
                exit;
            }
        }
        else
        {
            die("<script>alert(\"E-mail或密码错误,请重新登录!\"); window.location='login_form.php?mail=$mail';</script>");
        }
    }
    if($_COOKIE['userid']!=""&&$_COOKIE['userpwd']!="")
    {
        $userid = $_COOKIE['userid'];
        $userpwd = $_COOKIE['userpwd'];
        $sql = "SELECT * FROM `user` WHERE `id` = $userid AND `pwd` = '$userpwd'";
        mysql_query("SET NAMES UTF8");
        $result = mysql_query($sql,$conn);
        $user = @mysql_fetch_array($result);
        if($user[0]!="")
        {
            setcookie(userid,$user[id],time()+3600);
            setcookie(userpwd,$user[pwd],time()+3600);
        }
        else
        {
            setcookie(userid,"");
            setcookie(userpwd,"");
            die("<script>alert(\"密码已经更改,请重新登录!\"); window.location='login_form.php';</script>");
        }
    }
    else
    {
        //记录上一个URL以便登录后自动转到页面
        setcookie("lasturl",$_SERVER['REQUEST_URI']);
        die("<script>alert(\"没有登录或登录已经超时,请登录!\"); window.location='login_form.php';</script>");
    }
    ?>
      

  6.   

    运行看有没有以下变量
    $_SERVER['REQUEST_URI'] 
    $_SERVER["PHP_SELF"]