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/create/index.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'public/create') diff --git a/public/create/index.php b/public/create/index.php index 00ce794..786b8f2 100644 --- a/public/create/index.php +++ b/public/create/index.php @@ -3,21 +3,31 @@ declare(strict_types=1); use DTS\Bookmark; +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()); + $template = new Template($config['path_to_templates']); $bookmark = new Bookmark(); -$html = $template->render('create', compact('bookmark')); +$html = $template->render('create', compact( + 'bookmark', + 'errors' +)); respondAndExit(200, 'OK', $html); -- cgit v1.2.3-13-gbd6f