blob: b55e084be50e854a53e986b9ae7b24870b08bba2 (
plain)
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
|
<!DOCTYPE html>
<?php require "../lib/login.php"; ?>
<?php if_privileged(PRIVILEGE_ADMIN, "/") ?>
<?php
$res = $cursor->query("select max(id)+1 as id from webs.category");
$obj = $res->fetch_object();
$new_id = $obj->id;
?>
<?php do {
if ($_SERVER['REQUEST_METHOD'] !== 'POST') break;
$name = $_POST['name'];
$parent = $_POST['parent'];
if (!$name) break;
if (!$parent) $parent = null;
$statement = $cursor->prepare("insert into webs.category (`name`, `parent`) values (?, ?)");
$statement->bind_param("si", $name, $parent);
$statement->execute();
} while (false); ?>
<html>
<head>
<?php include 'head.php' ?>
<title>categorie toevoegen</title>
<link rel="stylesheet" href="admin.css">
</head>
<body>
<?php include 'navbar.php' ?>
<div class="main limwidth">
<h2>categorie toevoegen</h2>
<form action="/admin-category.php" method="post">
<label for="id">ID (automatisch)</label>
<input id="id" type="text" disabled value="<?php echo $new_id; ?>">
<label for="name">Naam</label>
<input id="name" name="name" type="text" placeholder="Naam">
<label for="parent">Bovenliggende categorie</label>
<select id="parent" name="parent">
<option value="0">(geen)</option>
<?php
$res = $cursor->query("select id, name from webs.category");
while ($c = $res->fetch_object()) echo "<option value='$c->id'>$c->name</option>";
?>
</select>
<input id="submit" type="submit" value="Toevoegen">
</form>
</div>
<?php include 'footer.php' ?>
</body>
</html>
|