-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_comment.php
More file actions
36 lines (28 loc) · 828 Bytes
/
Copy pathdelete_comment.php
File metadata and controls
36 lines (28 loc) · 828 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
29
30
31
32
33
34
35
36
<?php
session_start();
require_once ('conn.php');
require_once ('utils.php');
if (empty($_GET['id'])) {
header('Location: index.php?errCode=1');
die('The information is incomplete.');
}
$id = $_GET['id'];
$username = $_SESSION['username'];
$user = getUserFromUsername($username);
print_r($user);
$sql = "UPDATE peipei_comments SET is_deleted=1 WHERE id=? AND username=?";
if (isAdmin($user)) {
$sql = "UPDATE peipei_comments SET is_deleted=1 WHERE id=?";
}
$stmt = $conn->prepare($sql);
if (isAdmin($user)) {
$stmt->bind_param('i', $id);
} else {
$stmt->bind_param('is', $id, $username);
}
$result = $stmt->execute();
if (!$result) {
die($conn->error);
}
header('Location: index.php');
?>