I'm trying to get an input from a user-input box and put it in an SQL database but it returns an error every time.
Here is my code:
<?php
include_once("./assets/inc/connect.inc.php");
$myusername = $_SESSION["myusername"];
if (isset($_POST["post_bar"])) {
$post_status = $_POST["post_bar"];
$date = date('m/d/Y h:i:s a', time());
$loves = "0";
$post_query = "INSERT INTO `posts` (post, posted_by, posted_at, loves) VALUES ($post_status, $myusername, $date, $loves)";
$post_query_response = mysql_query($post_query);
if ($post_query_response) {
echo "<script>alert('Posted!');</script>";
}
else {
echo "<script>alert('Error, not posted.');</script>";
}
}
?>
<div class="post">
<p id="postfeed"></p>
</div>
<div class="share-box">
<div class="shareboxextender" >
<form method="POST" action="" name="post_bar" >
<input type="input" name="post_bar" placeholder="Share..." class="sharebox" autocomplete="off" />
</form>
</div>
</div>
I would really appreciate some help with this! Thank you.