aboutsummaryrefslogtreecommitdiff
path: root/public/omdömen/edit.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/omdömen/edit.php')
-rw-r--r--public/omdömen/edit.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/public/omdömen/edit.php b/public/omdömen/edit.php
new file mode 100644
index 0000000..00b2d3b
--- /dev/null
+++ b/public/omdömen/edit.php
@@ -0,0 +1,33 @@
+<?php
+require "../../include/sqlite.php";
+
+session_start();
+
+if (!isset($_SESSION["editable review"])) die("Kan ej redigera något omdöme.");
+
+$rowid = $_SESSION["editable review"];
+$res = query('select name, content from reviews where rowid = ?', $rowid);
+$review = (object) $res->fetchArray();
+
+if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ $name = $_POST["name"];
+ $content = $_POST["content"];
+
+ query("update reviews set name = ?, content = ? where rowid = ?", $name, $content, $rowid);
+
+ header("HX-Redirect: /omd%c3%b6men/");
+ exit;
+}
+
+require "../../include/layout.php"; layout($_);
+?>
+
+<form hx-post="/omdömen/edit/">
+ <label for="name">Namn:</label>
+ <input type="text" name="name" id="name" value="<?= htmlspecialchars($review->name) ?>">
+ <br>
+ <label for="content" style="vertical-align: top">Omdöme:</label>
+ <textarea name="content" id="content" style="height: 10em; width: 20em"><?= htmlspecialchars($review->content) ?></textarea>
+ <br>
+ <button>Skicka!</button>
+</form>