From c94c7f9b45f4b6db34886398b9b93efa635675b7 Mon Sep 17 00:00:00 2001 From: Illia Hromovoi Date: Thu, 3 Jul 2025 12:19:19 +0200 Subject: [PATCH 1/3] user delete account --- CSS/style_columns.css | 1 + Controller/UserController.php | 5 +++++ Model/UserModel.php | 8 ++++++++ Views/User/showUserAccountPage.phtml | 22 +++++++++++++++++----- Views/header.phtml | 3 ++- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CSS/style_columns.css b/CSS/style_columns.css index 4541368..21a3dd6 100644 --- a/CSS/style_columns.css +++ b/CSS/style_columns.css @@ -11,6 +11,7 @@ max-width: 90%; padding: 24px 42px 24px 42px; margin: 0 auto; + color: var(--brand-white); } .row { diff --git a/Controller/UserController.php b/Controller/UserController.php index 368b018..f9fc00e 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -167,4 +167,9 @@ class UserController{ public function showUserAccountPage (){ } + + public function deleteUser(){ + $userId = $_SESSION["user_id"]; + $this->db->deleteUser($userId); + } } \ No newline at end of file diff --git a/Model/UserModel.php b/Model/UserModel.php index 83973fd..6a84094 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -59,4 +59,12 @@ class UserModel extends Database return $sth->fetch(); } + public function deleteUser($id){ + $pdo = $this->linkDB(); + $sql = "DELECT * FROM user WHERE id = :id"; + $sth = $pdo->prepare($sql); + $sth->execute([":id" => $id]); + return $sth->fetch(); + } + } \ No newline at end of file diff --git a/Views/User/showUserAccountPage.phtml b/Views/User/showUserAccountPage.phtml index 80b531e..0aa43a0 100644 --- a/Views/User/showUserAccountPage.phtml +++ b/Views/User/showUserAccountPage.phtml @@ -6,11 +6,23 @@
-
- - - -
+

Hallo, + +
+ Hier können Sie ihren Account verwalten. +

+
+
+ + + +
+
+ + + +
+
diff --git a/Views/header.phtml b/Views/header.phtml index 1854b4a..1ae24a7 100644 --- a/Views/header.phtml +++ b/Views/header.phtml @@ -43,4 +43,5 @@ -
\ No newline at end of file + +
\ No newline at end of file From a0416cdefee24dad77641d3b7024282d8324f612 Mon Sep 17 00:00:00 2001 From: Illia Hromovoi Date: Thu, 3 Jul 2025 12:42:11 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Funktionalit=C3=A4t=20f=C3=BCrs=20L=C3=B6sc?= =?UTF-8?q?hen=20des=20Accounts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/UserController.php | 18 ++++++++++++++---- Model/UserModel.php | 8 +++++--- Views/User/showUserDeleteConfirmation.phtml | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 Views/User/showUserDeleteConfirmation.phtml diff --git a/Controller/UserController.php b/Controller/UserController.php index f9fc00e..286bab7 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -147,7 +147,7 @@ class UserController{ } public function clearUserSession(){ - unset($_SESSION["user_id"], $_SESSION["user_role"]); + unset($_SESSION["user_id"], $_SESSION["user_role"], $_SESSION["vorname"], $_SESSION["name"]); } public function logout(){ @@ -168,8 +168,18 @@ class UserController{ } - public function deleteUser(){ - $userId = $_SESSION["user_id"]; - $this->db->deleteUser($userId); + public function showUserDeleteConfirmation(){ + + } + + public function deleteAccount(){ + $userId = $_SESSION["user_id"] ?? ""; + if($userId){ + $this->db->deleteUser($userId); + $this->clearUserSession(); + $this->view->setDoMethodName("showUserDeleteConfirmation"); + $this->showUserDeleteConfirmation(); + } + } } \ No newline at end of file diff --git a/Model/UserModel.php b/Model/UserModel.php index 7b1831d..c96c367 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -61,10 +61,12 @@ class UserModel extends Database public function deleteUser($id){ $pdo = $this->linkDB(); - $sql = "DELECT * FROM user WHERE id = :id"; + $sql = "DELETE FROM user WHERE id = :id"; $sth = $pdo->prepare($sql); - $sth->execute([":id" => $id]); - return $sth->fetch(); + $sth->bindParam(":id", $id); + $sth->execute(); + $sth->execute(); + // echo "Benutzer ist gelöscht"; } } \ No newline at end of file diff --git a/Views/User/showUserDeleteConfirmation.phtml b/Views/User/showUserDeleteConfirmation.phtml new file mode 100644 index 0000000..ff983b5 --- /dev/null +++ b/Views/User/showUserDeleteConfirmation.phtml @@ -0,0 +1,14 @@ + + +
+
+
+

Der Account wurde erfolgreich gelöscht

+ +
+
+
From ae3a653de4e2177ba667f58d85985fa9a187f8be Mon Sep 17 00:00:00 2001 From: Illia Hromovoi Date: Thu, 3 Jul 2025 12:53:34 +0200 Subject: [PATCH 3/3] =?UTF-8?q?neu=20template=20f=C3=BCr=20=C3=A4nderung?= =?UTF-8?q?=20von=20benutzerdaten=20(in=20progress)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/UserController.php | 11 ++++++++++- Model/UserModel.php | 2 -- Views/User/showUserAccountPage.phtml | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Controller/UserController.php b/Controller/UserController.php index 286bab7..f35db59 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -180,6 +180,15 @@ class UserController{ $this->view->setDoMethodName("showUserDeleteConfirmation"); $this->showUserDeleteConfirmation(); } - + } + + public function changeAccountData(){ + $userId = $_SESSION["user_id"] ?? ""; + if($userId){ + $this->db->changeUserData($userId); + $this->setUserSession($user); + $this->view->setDoMethodName("showUserDeleteConfirmation"); + $this->showUserDeleteConfirmation(); + } } } \ No newline at end of file diff --git a/Model/UserModel.php b/Model/UserModel.php index c96c367..8099c34 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -65,8 +65,6 @@ class UserModel extends Database $sth = $pdo->prepare($sql); $sth->bindParam(":id", $id); $sth->execute(); - $sth->execute(); - // echo "Benutzer ist gelöscht"; } } \ No newline at end of file diff --git a/Views/User/showUserAccountPage.phtml b/Views/User/showUserAccountPage.phtml index 0aa43a0..d75be5b 100644 --- a/Views/User/showUserAccountPage.phtml +++ b/Views/User/showUserAccountPage.phtml @@ -22,6 +22,11 @@ +
+ + + +