【问题标题】:XAMPP Server Error (Error 500)XAMPP 服务器错误(错误 500)
【发布时间】:2017-12-30 18:36:03
【问题描述】:

服务器遇到内部错误,无法完成您的请求。服务器过载或 CGI 脚本中存在错误。 如果您认为这是服务器错误,请联系网站管理员。 错误 500 本地主机 Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30

我打开日志错误发现问题出在我的 user.inc.php 中的 header() 上:

function getLogin($conn){
if(isset($_POST['login']))
{
    $uid=$_POST['uid'];
    $pwd=$_POST['pwd'];

    $sql= "SELECT * FROM user WHERE uid='$uid' AND pwd ='$pwd'";
    $result=$conn->query($sql);
    if (mysqli_num_rows($result) == 1){
        if($row = $result->fetch_assoc()){

                $_SESSION['id'] = $row['id'];
                header("Location : index.php?loginsuccess");
                exit();
        }
    }
    else{



    }
}
}

错误日志:

[2017 年 7 月 25 日星期二 10:26:58.464402] [http:error] [pid 2380:tid 1656] [client ::1:49602] AH02429:响应标头名称“Location”包含无效字符、中止请求、引用:http://localhost/tgss/index.php

请帮忙。

【问题讨论】:

    标签: php html mysql apache xampp


    【解决方案1】:

    改变这个

    header("Location : index.php?loginsuccess");
    

    到这里

    header("Location: index.php?loginsuccess");
    

    错误来自Location 和冒号 (:) 之间的空格。

    我测试了您在冒号 (:) 之间有空格的 header("Location : index.php?loginsuccess");,它还返回了 Error 500

    【讨论】:

      【解决方案2】:
      header("Location : index.php?loginsuccess");
      

      使用下面一个

      header("Location: index.php?loginsuccess");
      

      它只在 Location: 之间提供错误空间,因此请删除像这样 Location 的空格:

      【讨论】:

        【解决方案3】:

        尝试改变

        header("Location : path");
        

        header("Location: path");
        

        【讨论】:

          【解决方案4】:

          header("Location: path"); login.php 之类的路径 位置的“L”应该是大写 没有间隙 b/w 'Location' 和 ':'

          【讨论】:

            猜你喜欢
            • 2018-08-19
            • 2016-03-10
            • 2014-10-02
            • 2017-05-25
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-06-19
            相关资源
            最近更新 更多