I have a form like this:
And the php file that is actioned is this:
But all it adds to the DB is a '1' for the headline and the same for the body, the image isn't working, neither is the date. Where have I gone wrong?
Code:
<form action="CreateNewNews.php" method="post" class="newNews"> //rest of the form </form>
Code:
<?php
include ('includes/DbCon.php');
$headline = isset($_POST['headline']);
$body = isset($_POST['body']);
$image = isset($_POST['image']);
$current_date = date("j/M/y");
if(isset($_POST['submit'])){
$query = $mysqli->prepare("INSERT INTO news (`headline`, `body`, `image`, `date`) VALUES ('$headline', '$body', '$image', '$current_date');");
$sql->execute(array(":headline" => headline, ":body" => body, ":image" => image, ":date" => $current_date));
echo '<script type="text/javascript">';
echo 'alert("News Items Saved")';
echo 'document.location.href = "/pc.v.2/admin-news.php";';
echo '</script>';
}
else
{
echo '<script type="text/javascript">';
echo 'alert("The news item was not able to be created. Please try again."). mysql_error()';
echo '</script>';
}
$mysqli->close();
?>
Comment