-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_category.php
executable file
·75 lines (66 loc) · 2.14 KB
/
add_category.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
<?php
session_start();
require_once 'classes/Util.php';
require_once 'classes/Category.php';
$util = new Util();
$util->validateUser();
$category = new Category();
$error_message = "";
$info = "";
if (isset($_POST['Add'])) {
$response = $category->addCategory($_POST['name']);
if (!$response) {
if (isset($_SESSION['error_message'])) {
$error_message = $_SESSION['error_message'];
unset($_SESSION['error_message']);
}
} else {
$info = "Category created successfully!";
}
}
?>
<!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'); ?>
<div id="register-label">
Create New Category
</div>
</section>
<section id="section4">
<form method="post" action="">
<table align="center" width="30%" cellpadding="2" cellspacing="5" border="0">
<?php if(!empty($error_message)) {
?>
<tr>
<td colspan="2">
<div class="error"><?php echo $error_message; ?></div>
</td>
</tr>
<?php } ?>
<?php if(!empty($info)) {
?>
<tr>
<td colspan="2">
<div class="info"><?php echo $info; ?></div>
</td>
</tr>
<?php } ?>
<tr>
<td align="right">Name</td>
<td><input type="text" name="name" id="name" placeholder="Name" required></td>
</tr>
<tr align="center">
<td colspan="2"><button type="submit" name="Add">Save</button></td>
</tr>
</table>
</form>
</section>
</body>
</html>