Before you mark this duplicate or mark down, please note none of the solutions I found online solved my problem. So I am trying to redirect people to /home.php after everything is uploaded.
<?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>
I know it has nothing to do with the html part because the code was not working before I added it in. I have all error reporting turned on so I have no idea what the problem is in my code.