Hi
I am trying to take data from a form and using php code insert it into a database but I get the following (see below); I have included the code below the error message, I can connect the the database OK and read values out it but not seem to write values to the database.
Thanks
Error Message Retunted......
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
PHP Code from Web Page;
<?php
session_start();
include('../include/db_connect.php');
if(!isset($_SESSION['user_id'])){
header('Location: blogadmin.php');
exit();
}
if(isset($_POST['submit'])){
//get blog data
$title = $_POST['title'];
$body = $_POST['body'];
$category = $_POST['category'];
$title = $db->real_escape_string($title);
$body = $db->real_escape_string($body);
$user_id = $_SESSION['user_id'];
$date = date('Y-m-d G:i:s');
$body = htmlentities($body);
if($title && $body && $category){
$query = $db->query("INSERT INTO posts (user_id, post_title, content, cat_id, date) VALUES('$user_id', '$title', '$body', '$category', '$date')");
if($query){
echo "Post Added";
}else{
echo "Error";
}
}else{
echo "Missing Data";
}
}
?>