From d4122f116c937e0ec509d8cefe540146ec27a0cd Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Wed, 20 Oct 2021 20:59:55 +0100 Subject: Validate fields --- public/edit/index.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'public/edit') 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); -- cgit v1.2.3-13-gbd6f