From c2a89680e6401a1e070d8b389b0dadbafc84adb4 Mon Sep 17 00:00:00 2001 From: okoibraun Date: Mon, 30 May 2022 16:11:18 +0100 Subject: [PATCH 1/2] changes to user class and made it inherit from CRUD class --- classes/User.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/classes/User.php b/classes/User.php index 82bb826..b4c2e07 100644 --- a/classes/User.php +++ b/classes/User.php @@ -1,49 +1,48 @@ query($query) or die($conn->error); - $row = $result->fetch_assoc(); + $data = $result->fetch_assoc(); - $returned = $result->num_rows; + $rows = $result->num_rows; - if($returned != 0) { - foreach($row as $key=>$value) { + if($rows != 0) { + foreach($data as $key=>$value) { $_SESSION[$key] = $value; } - return $row; + return $data; } else { return false; } } /** - * Log's Out a User that is logged in - * @param string - * @param string + * Log's Out the current user that is logged in + * @param string the action to perform or carry out after a successful logout + * @param string check if the action to be perform to know if it equal to logout */ public function logout($action, $check) { - if(isset($action) && $action == "logout" && isset($check) && $check == "true") { for($i=0; $i<=count($_SESSION); $i++) { $_SESSION[$i] = ""; unset($_SESSION[$i]); } - $destroy = session_destroy(); + session_destroy(); - return $destroy; + return true; } } From 350bba7e3bd325fdbfa35bd35a62ea3f20a8f926 Mon Sep 17 00:00:00 2001 From: okoibraun Date: Mon, 30 May 2022 16:14:31 +0100 Subject: [PATCH 2/2] added a line break in the logout methd --- classes/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/User.php b/classes/User.php index b4c2e07..5153bc5 100644 --- a/classes/User.php +++ b/classes/User.php @@ -34,6 +34,7 @@ public function login($conn, $query) { * @param string check if the action to be perform to know if it equal to logout */ public function logout($action, $check) { + if(isset($action) && $action == "logout" && isset($check) && $check == "true") { for($i=0; $i<=count($_SESSION); $i++) { $_SESSION[$i] = "";