forked from if-itb/IF3110-01-Simple-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_comment.php
21 lines (21 loc) · 917 Bytes
/
new_comment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$comment_id = uniqid();
$nama = $_POST['Nama'];
$post_id = $_POST['post_id'];
$comment_date = $_POST['comment_date'];
$komentar = $_POST['Komentar'];
$email = $_POST['Email'];
$con = mysqli_connect("localhost","root","","wbd_db");
$sql="INSERT INTO `comment` (`post_id`, `comment_id`, `email`, `nama`, `komentar`, `comment_date`) VALUES ('$post_id','$comment_id','$email','$nama','$komentar','$comment_date')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
mysqli_close($con);
echo '<li class="art-list-item">
<div class="art-list-item-title-and-time">
<h2 class="art-list-title"><a href="post.html">'.$nama.'</a></h2>
<div class="art-list-time">'.$comment_date.'</div>
</div>
<p>'.$komentar.'</p>
</li>';
?>