I have tried everything. This is my last resort. The code below is supposed to submit the info received from the form to the database to be displayed later. Now I know the query is correct but it does not run. I am sure this is some sort of typo that I just don't see, but any help would be greatly appreciated.
if($_SERVER['REQUEST_METHOD']=="POST"){
$blog = $_POST['blog_post'];
$time = date('Y-m-d h-m-s');
$id = $_SESSION['author_id'];
if($blog != ""){
$query = "INSERT INTO `blog`(`date`,`post`,`author_id`) VALUES('$time','$blog',$id)";
$result = mysqli_query($link, $query);
$row = mysqli_affected_rows($link);
if($result = mysqli_query($link,$query)){
include 'header.php';
$url = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url = rtrim($url, '/\\');
$url .= '/blog.php';
echo '<h3>Your blog has been posted. Go to <a style="color:white" href="'.$url.'">'.$url.'</a>';
include 'footer.php';
}else{
echo "that didn't work";
}
}else{
include 'header.php';
echo '<h1>You did not enter a blog post. Please try again.';
include 'footer.php';
}
}else{
redirect('index.php');
}
?>