-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategories.php
More file actions
executable file
·92 lines (79 loc) · 2.71 KB
/
categories.php
File metadata and controls
executable file
·92 lines (79 loc) · 2.71 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
<?php
session_start();
require_once 'classes/Util.php';
require_once 'classes/Category.php';
$util = new Util();
$util->validateAdmin();
$error_message = "";
if (isset($_SESSION['error_message'])) {
$error_message = $_SESSION['error_message'];
unset($_SESSION['error_message']);
}
$category = new Category();
$categories = $category->getAllCategories();
?>
<!DOCTYPE html>
<html>
<head>
<title>Home - Recipes of the World</title>
<?php include_once('meta.php'); ?>
</head>
<body>
<?php include_once('header.php'); ?>
<section id="section1">
<?php
include_once '_logout.php';
if(!empty($error_message)) {
?>
<div class="error"><?php echo $error_message; ?></div>
<?php
}
?>
<a href="settings.php" id="new-recipe-link">
<button>Admin Settings</button>
</a>
</section>
<section id="section3">
<div id="instruction">(Categories Management) <a href="add_category.php">Add New</a></div>
</section>
<section id="section4">
<table width="100%" cellpadding="5" cellspacing="5" id="recipe-list">
<tr align="left" class="alternate">
<th>Name</th>
<th>Added By</th>
<th colspan="2" align="center">Actions</th>
</tr>
<?php
$i = 0;
foreach ($categories as $line) {
?>
<tr class="<?php echo $i % 2 == 0 ? '' : 'alternate'; ?>">
<td>
<?php echo $line['description']; ?>
</td>
<td>
<?php echo $line['username']; ?>
</td>
<td>
<a href="edit_category.php?category_id=<?php echo $util->encryptPK($line['id']); ?>">Edit</a>
</td>
<td>
<a href="#" onclick="return validateDelete(<?php echo $util->encryptPK($line['id']);?>)">Delete</a>
</td>
</tr>
<?php
$i++;
}
?>
</table>
</section>
</body>
</html>
<script>
function validateDelete(categoryId) {
if (!confirm('Are you sure you want to delete this item permanently?')) {
return false;
}
window.location = 'delete_category.php?category_id=' + categoryId;
}
</script>