From f78088810796f936b7c3cc13f0e7c707d981e49b Mon Sep 17 00:00:00 2001 From: pbbfa23cse Date: Fri, 11 Jul 2025 22:55:51 +0200 Subject: [PATCH] fixed the redirect to handle everything properly --- Controller/TicketController.php | 29 +++++++++++++++++------------ Views/Ticket/buyTicketForm.phtml | 15 +++++++++++---- Views/Tickets/showTickets.phtml | 13 ++++++++++++- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Controller/TicketController.php b/Controller/TicketController.php index 783bc7f..c41c246 100644 --- a/Controller/TicketController.php +++ b/Controller/TicketController.php @@ -20,8 +20,9 @@ class TicketController { public function showTickets() { if (!isset($_SESSION['user_id'])) { - header('Location: index.php?controller=Auth&do=showLoginForm'); - exit; + $this->view->setVars(['error' => 'Bitte melden Sie sich an, um Ihre Tickets zu sehen.']); + $this->view->setDoMethodName('showLoginForm'); + return; } $tickets = $this->ticketModel->getUserTickets($_SESSION['user_id']); @@ -30,20 +31,23 @@ class TicketController { public function showBuyTicketForm() { if (!isset($_SESSION['user_id'])) { - header('Location: index.php?controller=Auth&do=showLoginForm'); - exit; + $this->view->setVars(['error' => 'Bitte melden Sie sich an, um Tickets zu kaufen.']); + $this->view->setDoMethodName('showLoginForm'); + return; } $event_id = $_GET['event_id'] ?? null; if (!$event_id) { - header('Location: index.php?controller=Event&do=showEvents'); - exit; + $this->view->setVars(['error' => 'Keine Event-ID angegeben.']); + $this->view->setDoMethodName('showEvents'); + return; } $event = $this->eventModel->getEvent($event_id); if (!$event) { - header('Location: index.php?controller=Event&do=showEvents'); - exit; + $this->view->setVars(['error' => 'Event nicht gefunden.']); + $this->view->setDoMethodName('showEvents'); + return; } // Check if user already has a ticket for this event @@ -107,8 +111,9 @@ class TicketController { public function deleteTicket() { if (!isset($_SESSION['user_id'])) { - header('Location: index.php?controller=Auth&do=showLoginForm'); - exit; + $this->view->setVars(['error' => 'Bitte melden Sie sich an.']); + $this->view->setDoMethodName('showLoginForm'); + return; } $ticket_id = $_GET['ticket_id'] ?? null; @@ -116,7 +121,7 @@ class TicketController { $this->ticketModel->deleteTicket($ticket_id); } - header('Location: index.php?controller=Ticket&do=showTickets'); - exit; + // Redirect to tickets page using JavaScript + $this->view->setVars(['redirect' => 'index.php?controller=Ticket&do=showTickets']); } } \ No newline at end of file diff --git a/Views/Ticket/buyTicketForm.phtml b/Views/Ticket/buyTicketForm.phtml index 6f8a5d0..75b8107 100644 --- a/Views/Ticket/buyTicketForm.phtml +++ b/Views/Ticket/buyTicketForm.phtml @@ -8,9 +8,10 @@ include dirname(__DIR__).'/header.phtml';
- - - +
+ Zurück zu den Events +
+

Beschreibung:

@@ -33,7 +34,7 @@ include dirname(__DIR__).'/header.phtml';

Möchten Sie ein Ticket für dieses Event kaufen?

Preis:

- +
@@ -49,4 +50,10 @@ include dirname(__DIR__).'/header.phtml';
+ + + + \ No newline at end of file diff --git a/Views/Tickets/showTickets.phtml b/Views/Tickets/showTickets.phtml index fdf5c7f..130ed28 100644 --- a/Views/Tickets/showTickets.phtml +++ b/Views/Tickets/showTickets.phtml @@ -8,7 +8,12 @@ include dirname(__DIR__).'/header.phtml';

Meine Tickets

- + +
+
+ Zum Login +
+
@@ -50,4 +55,10 @@ include dirname(__DIR__).'/header.phtml'; + + + + \ No newline at end of file