标头不起作用,没有错误

时间:2018-06-29 13:24:31

标签: php header

我的头文件现在根本无法使用,并且没有显示任何响应。
我的php文件如下所示:

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
ob_start();
session_start();
require('../in/connect.php');
require ('../password.php');
if (isset($_POST['signup'])) {
  $username = stripslashes($_POST['user']);
  $username = mysqli_real_escape_string($con,$username);
  $username = str_replace(" ", "_",$username);
  $password = stripslashes($_POST['pass']);
  $password = mysqli_real_escape_string($con,$password);
  $email = stripslashes($_POST['email']);
  $email = mysqli_real_escape_string($con,$email);
  $date = $_POST['date'];
  if (($date != '') && ($email != '') && ($password != '') && ($username != '')) {
  $passwordnew = (password_hash($password, PASSWORD_DEFAULT));
  $trn_date = date("Y-m-d H:i:s");
  $query = "INSERT into `users` (username, email, password, trn_date, birth_date)
         VALUES ('".$username."', '".$email."', '$passwordnew', '$trn_date','$date')";
        $result = mysqli_query($con,$query);
          if ($result){
            $sql = mysqli_query($con,"SELECT * FROM `users` where username = '".$username."'");
            $user = $sql->fetch_assoc();
        $id = $user['id'];
        $_SESSION['username'] = $user['username'];
        $_SESSION['id'] = $id;
        $_SESSION['password'] = $password;
        header("location:./");
        }
}
}
?>

我输入的内容和会话变量也一样,但没有重定向,日志中也没有错误。
已经检查了该线程How to fix "Headers already sent" error in PHP

1 个答案:

答案 0 :(得分:0)

确保您的查询

$ sql = mysqli_query($ con,“ SELECT * FROM DF1: Engagement Project_Name Jan Feb Mar Apr ... 336 prj_name_1 10 10 10 4 337 prj_name_2 23 10 86 0 338 prj_name_3 10 10 10 10 1001 prj_name_4 14 0 11 11 1002 prj_name_5 11 11 11 150 1003 prj_name_6 101 13 42 11 38 prj_name_7 14 14 14 146 DF2: Engagement Project_Name Month Value 336 prj_name_1 Jan 10 336 prj_name_1 Feb 10 336 prj_name_1 Mar 10 336 prj_name_1 Apr 4 ... 337 prj_name_2 Jan 23 337 prj_name_2 Feb 23 337 prj_name_2 Mar 23 337 prj_name_2 Apr 23 ... 338 prj_name_3 Jan 10 338 prj_name_3 Feb 10 338 prj_name_3 Mar 10 338 prj_name_3 Apr 10 ... 1001 prj_name_4 Jan 14 1001 prj_name_4 Feb 14 1001 prj_name_4 Mar 14 1001 prj_name_4 Apr 14 ... ,其中username ='”。$ username。“'”))

$ user = $ sql-> fetch_assoc();

不引发任何mysql错误

如果会抛出错误 标头将不起作用。 因为在标题之前,我们无法打印任何内容