aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-13 16:14:31 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-13 16:14:31 +0200
commite5e3cdb4da3b5c0f4298f84e80de5182b1f632c0 (patch)
tree7cce8b85a3a99173bcb007a95f6b2258289eef76 /public
parent4a6320cc87541dd9d997301cf138644e4564445c (diff)
admin category dinges klaar
Diffstat (limited to 'public')
-rw-r--r--public/admin-category.php33
-rw-r--r--public/admin-product.php9
2 files changed, 36 insertions, 6 deletions
diff --git a/public/admin-category.php b/public/admin-category.php
index a899b00..b55e084 100644
--- a/public/admin-category.php
+++ b/public/admin-category.php
@@ -1,16 +1,47 @@
<!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>
diff --git a/public/admin-product.php b/public/admin-product.php
index 9431cb2..8e04e30 100644
--- a/public/admin-product.php
+++ b/public/admin-product.php
@@ -6,8 +6,7 @@ $res = $cursor->query("select max(id)+1 as id from webs.product");
$obj = $res->fetch_object();
$new_id = $obj->id;
?>
-<?php
-do {
+<?php do {
if ($_SERVER['REQUEST_METHOD'] !== 'POST') break;
$name = $_POST['name'];
$description = $_POST['description'];
@@ -33,8 +32,7 @@ do {
$thumb = imagescale($image, 250);
$thumb_path = "img/product/$new_id-thumb.jpg";
imagejpeg($thumb, $thumb_path);
-} while (false);
-?>
+} while (false); ?>
<html>
<head>
<?php include 'head.php' ?>
@@ -45,6 +43,7 @@ do {
<?php include 'navbar.php' ?>
<div class="main limwidth">
<h2>product toevoegen</h2>
+ <p><a href="/admin-category.php">Categorie toevoegen</a></p>
<form action="/admin-product.php" method="post" enctype="multipart/form-data">
<label for="id">ID (automatisch)</label>
<input id="id" type="text" disabled value="<?php echo $new_id; ?>">
@@ -53,7 +52,7 @@ do {
<label for="price">Prijs</label>
<input id="price" name="price" type="number" value="0" min="0" max="999.99" step="0.01">
<label for="category">Categorie</label>
- <select id="category" name="category" placeholder="Categorie">
+ <select id="category" name="category">
<?php
$res = $cursor->query("select id, name from webs.category");
while ($c = $res->fetch_object()) echo "<option value='$c->id'>$c->name</option>";