-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
68 lines (61 loc) · 2.31 KB
/
delete.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
ob_start();
session_start();
require 'connect_db.php';
if (!empty($_SERVER['HTTP_COOKIE'])) {
var_dump($_COOKIE['PHPSESSID']);
var_dump(substr($_SERVER['HTTP_COOKIE'], 10));
$conn = mysqli_connect('localhost', 'root', '', 'assignment');
if ($conn->connect_error) {
echo '<script>alert("Connect Database fail!")</script>';
die();
}
//xóa người dùng
if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
if (!empty($_GET['id'])) {
if (isset($_SESSION['role']) && $_SESSION['role'] == 0) {
$id = $_GET['id'];
$stmt = $conn->prepare("DELETE FROM user WHERE id=? AND role=1");
$stmt->bind_param("i", $id);
$stmt->execute();
echo $stmt->get_result();
$stmt->close();
$conn->close();
header("Location: quanlysinhvien.php");
} else {
echo 'Miss Authorication';
}
}
} else {
echo 'Token khong khop';
}
if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
//xóa tin nhắn
if (!empty($_GET['idmess']) && (!empty($_GET['idttcn']) || !empty($_GET['iddsnd']))) {
$id = $_GET['idmess'];
$stmt = $conn->prepare("SELECT * FROM messenger WHERE idmess=?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result = mysqli_fetch_assoc($stmt->get_result());
if (isset($_SESSION['id']) && $_SESSION['id'] == $result['idgui']) {
$stmt = $conn->prepare("DELETE FROM messenger WHERE idmess=?");
$stmt->bind_param("i", $id);
$stmt->execute();
if (!empty($_GET['idttcn']) && !empty($_GET['username'])) {
header("Location: thongtincanhan.php?id=" . $_GET['idttcn'] . "&username=" . $_GET['username']);
};
if (!empty($_GET['iddsnd'])) {
header("Location: danhsachnguoidung.php?id=" . $_GET['iddsnd']);
}
} else {
echo 'Miss Authortication';
}
$stmt->close();
$conn->close();
}
} else {
echo 'Token khong khop';
}
} else {
echo 'Miss Authentication';
}