-
Notifications
You must be signed in to change notification settings - Fork 0
/
addCategory.php
50 lines (40 loc) · 1.26 KB
/
addCategory.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
<?php
include 'incs/header.php';
include 'classes/dbh.php';
if (isset($_SESSION['userId']) && $userRole == "user") {
header("Location: 404.php");
} elseif (!isset($_SESSION['userId'])) {
header("Location: 404.php");
}
$dbh = new Dbh();
?>
<body>
<?php
include 'incs/navBar.php';
?>
<div id="add-category-container">
<div class="row">
<div class="col-12">
<h1 class="text-center">Categorie toevoegen</h1>
</div>
</div>
<form class="login-form" method="post" action="">
<div class="form-control">
<input type="text" name="categoryName" id="categoryName" placeholder="Naam categorie" required>
<i class="fas fa-font"></i>
</div>
<button class="submit" type="submit" name="submit">Toevoegen</button>
</form>
</div>
<?php
if (isset($_POST['submit'])) {
$categoryName = $_POST['categoryName'];
$stmt = $dbh->connection()->prepare("INSERT INTO product_category (category_name) VALUES (:categoryName)");
$stmt->bindParam(':categoryName', $categoryName);
$stmt->execute();
header("Location: categories.php");
}
?>
<?php
include 'incs/footer.php';
?>