diff --git a/Controller/UserController.php b/Controller/UserController.php index 47d8654..016ab91 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -19,19 +19,27 @@ class UserController public function loginUser() { - var_dump($_POST); - echo $_POST["username"]; + $erg = array(); + $erg = $this->userModel->verifyLogin($_POST["username"], $_POST["password"]); + if ($erg["success"] == true) { + echo "success"; + } + else { + $this->view->setDoMethodName("showUserLoginForm"); + $this->view->setVars([ + "errmsg" => $erg["message"] + ]); + $this->showUserLoginForm(); + } - - // on fail - $this->view->setDoMethodName("showUserLoginForm"); - $this->showUserLoginForm(); } - public function showUserLoginForm() { + } + + } \ No newline at end of file diff --git a/Model/UserModel.php b/Model/UserModel.php index 798743e..3fdc540 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -2,12 +2,12 @@ namespace ppa\Model; use ppa\Model\ParticipantModel; -use ppb\Library\Msg; +//use ppb\Library\Msg; use PDOException; class UserModel extends Database { - function verifyLogin($pdo, $username, $password) + public function verifyLogin($username, $password) { $pdo = $this->linkDB(); if (!$pdo) return ['success' => false, 'message' => 'Database connection error.']; @@ -20,7 +20,7 @@ class UserModel extends Database $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; $_SESSION['role'] = $user['role']; // Store role - return ['success' => true, 'message' => 'Login successful!', 'redirect' => showNotes()]; + return ['success' => true, 'message' => 'Login successful!', 'redirect' => "xx"]; } return ['success' => false, 'message' => 'Invalid username or password.']; } catch (PDOException $e) { diff --git a/Views/User/showUserLoginForm.phtml b/Views/User/showUserLoginForm.phtml index cb0784f..25a63f0 100644 --- a/Views/User/showUserLoginForm.phtml +++ b/Views/User/showUserLoginForm.phtml @@ -13,10 +13,15 @@
- - + +

Don't have an account? Register here

-
+ + + \ No newline at end of file