-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_comment.php
35 lines (30 loc) · 971 Bytes
/
post_comment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
ini_set('display_errors', 1);
$host = "localhost:2023";
$username = "root";
$password = "";
$databasename = "comment";
$connect = mysqli_connect($host, $username, $password, $databasename);
if(isset($_POST['user_comm']) && isset($_POST['user_name']))
{
$comment = $_POST['user_comm'];
$name = $_POST['user_name'];
$insert = "insert into comments values('', '$name', '$comment', CURRENT_TIMESTAMP)";
$runInsert = mysqli_query($connect, $insert);
$select = "SELECT name, comment, post_time FROM comments where name='$name' and comment='$comment'";
$result = mysqli_query($connect, $select);
if($row = mysqli_fetch_assoc($result)) {
$name = $row['name'];
$comment = $row['comment'];
$time = $row['post_time'];
?>
<div class="comment_div">
<p class="comment"><?php echo $comment;?></p>
<p class="name">by: <?php echo $name;?></p>
<p class="time"><?php echo $time;?></p>
</div>
<?php
}
exit;
}
?>