-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit-category.php
More file actions
102 lines (66 loc) · 2.53 KB
/
edit-category.php
File metadata and controls
102 lines (66 loc) · 2.53 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
101
102
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sessions.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-db-connection.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-functions.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-header.php");
?>
<main>
<?php $user = getUsersDetails($member); ?>
<?php
if (!$user || $user['member_is_admin'] != "yes") {
stderr("<strong>Protected</strong> page.");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
die();
}
?>
<div class="row">
<div class="col-md-3">
<div class="card">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-dashboard.php"); ?>
</div>
<div class="card">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-dashboard-extended.php"); ?>
</div>
</div>
<div class="col-md-9">
<div class="card">
<div class="card-header"><i class="fas fa-upload"></i> Update Category</div>
<div class="card-body">
<?php
$errors = [];
if (isset($_POST['submitEditCategory'])) {
if (!empty($errors) > 0) {
foreach($errors as $error) {
echo "<div class=\"alert alert-danger\" role=\"alert\"><i class=\"fas fa-exclamation-triangle\"></i> {$error}</div>";
}
} else {
$u = DB::getInstance()->update(
'categories',
'category_id',
$_POST['updateId'],
[
'category_name' => $_POST['category_name']
]);
stdmsg("Your <strong>category</strong> has been <strong>updated</strong>.");
}
}
?>
<?php
$category = DB::getInstance()->selectValues("SELECT `category_name` FROM `categories` WHERE `category_id`='{$_GET['categoryId']}'");
?>
<form action="edit-category.php?categoryId=<?= $_GET['categoryId']; ?>" method="post">
<div class="mb-3">
<label for="category_name" class="form-label"><strong>Name:</strong></label>
<input type="text" class="form-control" id="category_name" name="category_name" value="<?= $category['category_name']; ?>" required>
</div>
<input type="hidden" name="updateId" value="<?= $_GET['categoryId']; ?>">
<button type="submit" name="submitEditCategory" class="btn btn-success float-end"><i class="fas fa-upload"></i> Update</button>
</form>
</div>
</div>
</div>
</div>
</main>
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
?>