-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_resource.php
130 lines (110 loc) · 4.02 KB
/
delete_resource.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
require "config/config.php";
$isDeleted = false;
if ( !isset($_GET['resource_id']) || empty($_GET['resource_id']) ) {
$error = "Invalid resource.";
}
else {
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ( $mysqli->connect_errno ) {
echo $mysqli->connect_error;
exit();
}
}
// Prepared statement
$statement = $mysqli->prepare("DELETE FROM resources WHERE id = ?");
$statement->bind_param("i", $_GET["resource_id"]);
$executed = $statement->execute();
if(!$executed) {
echo $mysqli->error;
exit();
}
if($statement->affected_rows == 1) {
$isDeleted = true;
}
$statement->close();
$mysqli->close();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>COVID-19 Report</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://kit.fontawesome.com/2b38a0d5c8.js" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css2?family=Karla:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container" id="header">
<div class="row">
<div class="col-12">
<nav class="navbar navbar-dark justify-content-center">
<a class="navbar-brand" href="index.html">
<h1><i class="fas fa-shield-virus fa-lg"></i> COVID-19 Report</h1>
</a>
</nav>
</div>
</div>
</div>
<div class="container" id="nav">
<div class="row">
<div class="col-12">
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="resources.php">Resources</a>
</li>
<li class="nav-item">
<a class="nav-link" href="bookmarks.html">Bookmarks</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container mb-5">
<div class="row">
<div class="col-12">
<?php if ( isset($error) && !empty($error) ) : ?>
<div class="alert alert-danger" role="alert">
<?php echo $error; ?>
</div>
<div class="form-group row text-center">
<div class="col-sm-3"></div>
<div class="col-sm-6 mt-2">
<a href="resources.php">Back</a>
</div>
<div class="col-sm-3"></div>
</div>
<?php endif; ?>
<?php if ($isDeleted) : ?>
<div class="alert alert-success" role="alert">
Resource has been deleted successfully.
</div>
<div class="form-group row text-center">
<div class="col-sm-3"></div>
<div class="col-sm-6 mt-2">
<a href="resources.php">Confirm</a>
</div>
<div class="col-sm-3"></div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="container" id="footer">
<div class="row">
<div class="col-12 mt-2 mb-5">
<p class="card-text">Crafted with <i class="fas fa-heart" id="heart"></i> by <a href="https://www.tranngo.com/">Tran Ngo</a></p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js" integrity="sha256-R4pqcOYV8lt7snxMQO/HSbVCFRPMdrhAFMH+vr9giYI=" crossorigin="anonymous"></script>
</body>
</html>