-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
executable file
·66 lines (57 loc) · 2.21 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
<?php
$deliveries = json_decode(file_get_contents('data/deliveries.json'));
if (!isset($_GET['id'])) {
die('Missing delivery ID');
}
$id = $_GET['id'];
if (!is_numeric($id) || !isset($deliveries->items->{$id})) {
die('Invalid delivery ID');
}
$delivery = $deliveries->items->{$id};
if ('POST' == $_SERVER['REQUEST_METHOD']) {
unset($deliveries->items->{$id});
file_put_contents('data/deliveries.json', json_encode($deliveries));
header('Location: /');
}
?>
<html>
<head>
<title>Deliveries</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"/>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
<link rel="stylesheet" href="css/main.css"/>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function() {
$('#deliveryDate').datepicker({
'dateFormat': 'yy-mm-dd'
});
});
</script>
</head>
<body>
<div class="container">
<header class="header clearfix">
<nav>
<ul class="nav nav-pills float-right">
<li class="nav-item">
<a class="nav-link" href="/">Deliveries</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/create.php">New Delivery</a>
</li>
</ul>
</nav>
<h3 class="text-muted">CartonCloud</h3>
</header>
<main role="main">
<h1>Delete Delivery</h1>
<form action="delete.php?id=<?php echo htmlentities($id); ?>" method="POST">
<p>Are you sure you want to delete this delivery?</p>
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</main>
</div>
</body>
</html>