在您标记此副本或标记之前,请注意我在网上找到的解决方案都没有解决我的问题。因此,我尝试在上传所有内容后将人员重定向到 /home.php 。
<?php
session_start();
ini_set('display_errors',1);
error_reporting(E_ALL | E_WARNING | E_NOTICE);
include('head.php');
$title = $_POST['title'];
$title = stripslashes($title);
$title = mysqli_real_escape_string($conn, $title);
$preview = $_POST['preview'];
$preview = stripslashes($preview);
$preview = mysqli_real_escape_string($conn, $preview);
$thumbnail = $_POST['thumbnail'];
$thumbnail = stripslashes($thumbnail);
$thumbnail = mysqli_real_escape_string($conn, $thumbnail);
$category = $_POST['category'];
$category = stripslashes($category);
$category = mysqli_real_escape_string($conn, $category);
$content = $_POST['content'];
$content = stripslashes($content);
$content = mysqli_real_escape_string($conn, $content);
$content = str_replace('\r', '', $content);
$content = str_replace('\n', '</p><p>', $content);
$content = str_replace('</p><p> </p><p>', '</p><p>', $content);
$content = str_replace('</p><p></p><p>', '</p><p>', $content);
$content = str_replace('</p><p>\r\n</p><p>', '</p><p>', $content);
$content = str_replace(' i ', ' I ', $content);
//To capitalize I's.
$author = $_SESSION['id'];
if ($_SESSION['rank'] == 2) {
$status = 1;
}
else {
$status = 0;
}
$sql = mysqli_query($conn, "INSERT INTO article (title, preview, author, thumbnail, section, content, status) VALUES ('$title', '$preview', '$author', '$thumbnail','$category', '$content', $status)");
if ($sql == true) {
$section = strtolower($category);
print $section;
flush();
header('location:/home.php');
}
else {
print "Did not work.";
}
?>
<style>
html {background: #FFFFFF;}
</style>
我知道它与html部分无关,因为代码在我添加之前没有工作。我已经打开了所有错误报告,所以我不知道代码中的问题是什么。
答案 0 :(得分:0)
尝试在重定向下方添加exit;
。
header('location:/home.php');
exit;