XAMPP 服务器错误(错误 500)

新手上路,请多包涵

服务器遇到内部错误,无法完成您的请求。服务器过载或 CGI 脚本中有错误。如果您认为这是服务器错误,请联系网站管理员。错误 500 localhost 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”包含无效字符,中止请求,referer: http: //localhost/tgss/index.php

请帮忙。

原文由 Joshua Nugraha 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 699
2 个回答

改变这个

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

对此

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

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

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

原文由 Rex Martinus 发布,翻译遵循 CC BY-SA 3.0 许可协议

header("Location: path"); 像 login.php 这样的路径 Location 的 ‘L’ 应该是大写的,没有间隙 b/w ‘Location’ 和 ‘:’

原文由 Abhishek Dulat 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题