-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.php
More file actions
28 lines (27 loc) · 813 Bytes
/
comment.php
File metadata and controls
28 lines (27 loc) · 813 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
25
26
27
28
<?php
include("./connection.php");
$time = date('Y-m-d H:i:s');
$return_data = array(
"status_code" => "200",
);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user = $_POST['user'];
$content = $_POST['content'];
$post_id = $_POST['post_id'];
$user_id = $_POST['id'];
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$user = $_GET['user'];
$content = $_GET['content'];
$post_id = $_GET['post_id'];
}
$class = intval($class);
$post_sql = "INSERT INTO comment VALUES(null,'$user','$content','$time',$post_id,0,$user_id)";
$query = mysqli_query($connection, $post_sql);
if ($query != false) {
echo json_encode($return_data);
} else {
$return_data["status_code"] = "404";
echo json_encode($return_data);
}
// $comment_sql = "INSERT INTO comment VALUES(null,$user,$content)";