From fdffdbecf0b21aea7b78323b7e55e00c2b6800f6 Mon Sep 17 00:00:00 2001 From: Bitha17 <16521076@mahasiswa.itb.ac.id> Date: Thu, 5 Oct 2023 02:17:18 +0700 Subject: [PATCH] edit logout handling --- app/Controllers/UserController.php | 5 +++++ home.php | 6 +++--- index.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index fe2e83a..5bfaee1 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -105,6 +105,11 @@ class UserController { header("Location:Views/login/register.php"); ob_end_flush(); } + } elseif ($_POST['userAction'] === 'logout') { + echo "here"; + $this->logout(); + header("Location:Views/login/login.php"); + ob_end_flush(); } else { // Handle other actions here, if needed } diff --git a/home.php b/home.php index a043c9f..072ce25 100644 --- a/home.php +++ b/home.php @@ -105,8 +105,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $loginEmail = $_POST['loginEmail']; $loginPassword = $_POST['loginPassword']; echo $userController->loginByEmail($loginEmail,$loginPassword); - } elseif ($_POST['userAction'] === 'logout') { - echo $userController->logout(); + // } elseif ($_POST['userAction'] === 'logout') { + // echo $userController->logout(); } } } @@ -142,7 +142,7 @@ $users = $userController->getAllUsers(); <li><a href="#">History</a></li> <!-- Logout Button --> <li> - <form method="post" action="home.php"> + <form method="post" action="app/router.php"> <button type="submit" name="userAction" value="logout">Logout</button> </form> </li> diff --git a/index.php b/index.php index 87b6394..57bc80c 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ <li><a href="#">History</a></li> <!-- Logout Button --> <li> - <form method="post" action="home.php"> + <form method="post" action="app/router.php"> <button type="submit" name="userAction" value="logout">Logout</button> </form> </li> -- GitLab