forked from if-itb/IF3110-01-Simple-Blog
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcomment.php
More file actions
24 lines (20 loc) · 716 Bytes
/
comment.php
File metadata and controls
24 lines (20 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$con=mysqli_connect("localhost","root","","simpleblog");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
date_default_timezone_set("Asia/Jakarta");
$komentar = mysqli_real_escape_string($con, $_POST['komentar']);
$nama = mysqli_real_escape_string($con, $_POST['nama']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$date = date("Y-m-d H:i:s");
$sql="INSERT INTO comments (post_id, comment_name, comment_email, comment_date, comment_content)
VALUES ('$_POST[id]',' $nama', '$email', '$date' , '$komentar')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}else{
echo "true";
}
mysqli_close($con);
?>