summaryrefslogtreecommitdiff
path: root/public/edit
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2021-10-20 20:59:55 +0100
committerDavid T. Sadler <davidtsadler@googlemail.com>2021-10-20 20:59:55 +0100
commitd4122f116c937e0ec509d8cefe540146ec27a0cd (patch)
tree481f90c4d774d32c89e612594158fe4a2d7328a4 /public/edit
parent1a112ab14becaf6d41cd34c176cbe563d4ca9742 (diff)
Validate fields
Diffstat (limited to 'public/edit')
-rw-r--r--public/edit/index.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/public/edit/index.php b/public/edit/index.php
index 9d3d4c0..fba5a90 100644
--- a/public/edit/index.php
+++ b/public/edit/index.php
@@ -3,17 +3,24 @@
declare(strict_types=1);
use DTS\BookmarkRepository;
+use DTS\Errors;
+use DTS\Session;
use DTS\Template;
+
use function DTS\Functions\respondAndExit;
require_once(__DIR__.'/../../autoload.php');
$config = require_once(__DIR__.'/../../config.php');
+$session = Session::getInstance();
+
if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'GET') {
respondAndExit(405, 'Method Not Allowed');
}
+$errors = $session->get('errors', new Errors());
+
$id = filter_input(INPUT_GET, 'id');
$bookmarks = new BookmarkRepository($config['path_to_repository']);
@@ -26,6 +33,9 @@ if ($bookmark === null) {
respondAndExit(404, 'Not Found');
}
-$html = $template->render('edit', compact('bookmark'));
+$html = $template->render('edit', compact(
+ 'bookmark',
+ 'errors'
+));
respondAndExit(200, 'OK', $html);