From 40997195b7ee07cb1bda978186c1804371e1f16e Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Sat, 13 Nov 2021 09:22:25 +0000 Subject: Create site --- public/update/index.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 public/update/index.php (limited to 'public/update') diff --git a/public/update/index.php b/public/update/index.php new file mode 100644 index 0000000..82b3c3f --- /dev/null +++ b/public/update/index.php @@ -0,0 +1,56 @@ +find($id); + +if ($todo === null) { + respondAndExit(404, 'Not Found'); +} + +$old = new Old($_REQUEST); + +$session->set('old', $old); + +$validator = new Validator($_REQUEST); + +if ($validator->errors->count()) { + $session->set('errors', $validator->errors); + + redirectAndExit("/edit?id=$todo->id"); +} + +$validated = $validator->validated; + +$todo->task = $validated->task; +$todo->tag = $validated->tag; + +if (!$todos->update($todo)) { + respondAndExit(500, 'Internal Server Error'); +} + +$session->set('message', 'Todo Updated'); + +redirectAndExit('/'); -- cgit v1.2.3-13-gbd6f