From b628de165c3a0f117ec620c1d78a0045c1fe5210 Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Mon, 7 Feb 2022 15:14:52 +0100 Subject: [PATCH] Add login error message --- src/classes/page.php | 58 ++++++++++++++++++++++++++++++++++++++++++++ src/pages/login.php | 14 ++++++++--- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/classes/page.php b/src/classes/page.php index d59da4c4..118d5e84 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -215,4 +215,62 @@ class Page +
+ + + + +
+ +
+ + + +

+ +
+
+ message($content, $header, 'error'); + } + + public function warning(string $content, string $header = ''): void + { + $this->message($content, $header, 'warning'); + } + + public function info(string $content, string $header = ''): void + { + $this->message($content, $header, 'info'); + } } diff --git a/src/pages/login.php b/src/pages/login.php index 1e39d725..3ab019ac 100644 --- a/src/pages/login.php +++ b/src/pages/login.php @@ -1,7 +1,7 @@ */ @@ -25,9 +25,9 @@ if (isset($_POST['email'], $_POST['password'])) { AND `password` = "' . $password . '";' )->fetch(); - if (false === $user) { - # code... - } else { + $success = false !== $user; + + if ($success) { $_SESSION['user'] = $user; } } @@ -44,6 +44,12 @@ $page->navigation();

title ?>

+ error('Invalid credentials!', 'Error'); + } + ?> +