I'm trying to insert some data into my database but it doesn't work, I don't see the error, can someone help? $by = $_SESSION['on']
is the user that's logged in.
Here is my source code.
<?php
session_start();
?>
<form method="post" action="">
<input type="text" name="title" placeholder="Title"><br>
<input type="text" name="content" placeholder="Content"><br>
<input type="date" name="date"><br>
<input type="submit" name="submit" value="send">
</form>
<?php
include("databaseconnectie.php");
if(isset($_POST['submit'])) {
$content = $_POST['content'];
$by = $_SESSION['on'];
$title = $_POST['title'];
$date = $_POST['date'];
$query = $db->prepare("INSERT INTO posts (content, date, by, title) VALUES(:content, :date, :by, :title)");
$query->bindParam("content", $content);
$query->bindParam("by", $by);
$query->bindParam("title", $title);
$query->bindParam("date", $date);
$query->execute();
echo "Trade Added";
echo "<br>";
}
?>