-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.php
More file actions
100 lines (88 loc) · 3.08 KB
/
Copy pathedit.php
File metadata and controls
100 lines (88 loc) · 3.08 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
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
<?php
session_start();
// catch err
if (isset($_GET['error'])) {
$err = htmlspecialchars($_GET['error']);
echo "<script>alert('error, $err');</script>";
}
// if user try to find id via url
if (!isset($_GET['id']) || $_GET['id'] === '') {
header('Location: /index.php?error=invalid_id');
}
$found = false;
foreach ($_SESSION['packages'] as $package) {
if ($package['id'] === $_GET['id']) {
$package_name = $package['package-name'];
$category = $package['category'];
$source = $package['source'];
$notes = $package['notes'];
$found = true;
break;
}
}
// package not found
if (!$found) {
header('Location: /index.php?error=package_not_found');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="assets/img/favicon.png">
<link rel="stylesheet" href="assets/css/edit.css">
<title>Arch Package Tracker</title>
</head>
<body>
<div class="container">
<div class="wrapper">
<h1>Edit Package</h1>
<form action="edit-process.php" method="post">
<input type="hidden" name="id" value="<?= htmlspecialchars($_GET['id']) ?>">
<table>
<tr>
<td>
<label for="package-name" class="required">Package Name</label>
</td>
<td>
<input type="text" name="package-name" id="package-name" required value="<?= htmlspecialchars($package_name) ?>">
</td>
</tr>
<tr>
<td>
<label for="category">Category</label>
</td>
<td>
<input type="text" name="category" id="category" value="<?= htmlspecialchars($category) ?>">
</td>
</tr>
<tr>
<td>
<label for="source" class="required">Source</label>
</td>
<td>
<input type="text" name="source" id="source" required value="<?= htmlspecialchars($source) ?>">
</td>
</tr>
<tr>
<td>
<label for="notes">Notes</label>
</td>
<td>
<input type="text" name="notes" id="notes" value="<?= htmlspecialchars($notes) ?>">
</td>
</tr>
<tr>
<td><a href="index.php" class="back-button">← Back</a></td>
<td>
<input type="submit" value="Submit" class="submit-button">
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>