-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdeletereply.php
More file actions
45 lines (37 loc) · 1.27 KB
/
deletereply.php
File metadata and controls
45 lines (37 loc) · 1.27 KB
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
36
37
38
39
40
41
42
43
44
45
<?php
include('init.php');
if($_SERVER['REQUEST_METHOD']=="POST"){
$messages=array();
$response=array();
$post_id = $_POST['post_id'];
$comment_id = $_POST['comment_id'];
$user_id = $_POST['user_id'];
$access_token_post=$_POST['access_token'];
$sql = "SELECT * FROM threads WHERE id=$comment_id";
$result = query($sql);
$row = fetch_array($result);
$user_id_post = $row['user_id'];
$sql = "SELECT * FROM alumnus WHERE id=$user_id_post";
$result = query($sql);
$row = fetch_array($result);
$access_token = $row['access_token'];
if($user_id==$user_id_post && $access_token==$access_token_post){
$sql= "DELETE FROM threads WHERE post_id=$post_id and id=$comment_id";
$result = query($sql);
if($result){
$sql = "UPDATE posts SET no_of_comment = no_of_comment-1 WHERE id=$post_id";
$res4 = query($sql);
$response['status']=209;
$messages[]="Comment deleted succsesfully!";
}else{
$response['status']=408;
$messages[]="Retry";
}
}else{
$response['status'] = 409;
$message[]="Unauthorized access";
}
$response['messages'] = $messages;
echo json_encode($response);
}
?>