我试图将一些数据插入到我的数据库中,但它不起作用,我没有看到错误,有人可以帮忙吗? $by = $_SESSION['on']
是已登录的用户。
这是我的源代码。
<?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>";
}
?>