当我运行我的php脚本时,它无法正常工作。
出现“警告:无法修改标题信息-已发送标题”。 我搜索了有关此问题的一些信息,但没有任何效果。 这是我的代码:
<?php
session_start();
?>
<?php
$date = filter_var(trim($_POST['date']), FILTER_SANITIZE_STRING);
$surename = filter_var(trim($_POST['surename']), FILTER_SANITIZE_STRING);
$name = filter_var(trim($_POST['name']), FILTER_SANITIZE_STRING);
$patronymic = filter_var(trim($_POST['patronymic']), FILTER_SANITIZE_STRING);
$email = filter_var(trim($_POST['email']), FILTER_SANITIZE_STRING);
$time = filter_var(trim($_POST['time']), FILTER_SANITIZE_STRING);
$pass = filter_var(trim($_POST['pass']), FILTER_SANITIZE_STRING);
$org = filter_var(trim($_POST['org']), FILTER_SANITIZE_STRING);
print_r($date);
if ($date == 0)
{
$_SESSION['error'] = "You haven't entered a date!";
header('Location: /');
exit();
}
if ($surename == 0)
{
$_SESSION['error'] = "You haven't entered a surename!";
header('Location: /');
exit();
}
if ($patronymic == 0)
{
$_SESSION['error'] = "You haven't entered a patronymic!";
header('Location: /');
exit();
}
if ($pass == 0)
{
$_SESSION['error'] = "You haven't entered a password!";
header('Location: /');
exit();
}
if ($name == 0)
{
$_SESSION['error'] = "You haven't entered a name!";
header('Location: /');
exit();
}
if ($time == "first")
$half = 1;
else
$half = 2;
$flag = false;
require "bd_connection.php";
$result = $mysql->query("SELECT * FROM `renters` WHERE (`data` = '$date' AND `half` = '$half')");
$renters = $result->fetch_assoc();
if (count($renters) == false)
{
$mysql->query("INSERT INTO `renters` (`surename`, `name`, `patronymic`, `data`, `half`, `organization`, `pass`, `email`) VALUES ('$surename', '$name', '$patronymic', '$date', '$half', '$org', '$pass', '$email')");
$flag = true;
}
else
{
$_SESSION['error'] = "This date and time have been already reserved!";
header('Location: /');
exit();
}
if ($flag == true)
{
$res = $mysql->query("SELECT * FROM `renters` WHERE (`data` = '$date' AND `half` = '$half')");
$renter = $res->fetch_assoc();
$string = $_FILES['file']['name'];
$id = $renter['id'];
if ($string == "")
{
$_SESSION['error'] = $string."You haven't attached file!";
$mysql->query("DELETE FROM `renters` WHERE `id` = $id");
header('Location: /');
exit();
}
else
{
$string = explode("." , $string, PHP_INT_MAX);
$fileName = $id.".".$string[count($string)-1];
move_uploaded_file($_FILES['file']['tmp_name'], "../docs/".$fileName);
$_SESSION['success'] = "Successfully reseved for ".$date." !";
}
$mysql->query("UPDATE `renters` SET `doc` = '$fileName' WHERE `id` = '$id'");
}
$mysql->close();
header('Location: /');
exit();
?>
如您所见,我放了session_start();一开始 另外,我正在使用没有BOM的UTF-8。