【发布时间】:2016-07-07 00:33:08
【问题描述】:
在标记此重复或标记之前,请注意我在网上找到的解决方案都没有解决我的问题。所以我试图在上传所有内容后将人们重定向到 /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 部分无关,因为在我添加之前代码无法正常工作。我已打开所有错误报告,所以我不知道我的代码有什么问题。
【问题讨论】:
-
你没有描述问题是什么
-
问题是代码的行为好像header();不在那里。
-
header("Location: FULLURL");字段名不区分大小写。 -
好吧,慢慢添加这段代码,直到你找到破坏它的地方
-
print $section; flush(); header('location:/home.php');您在此处的标题之前输出。我现在放弃你的问题;你说没有错误,我觉得这很难相信。编辑:@Dagon 我也是。