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';
Beschreibung: = nl2br(htmlspecialchars($event['description'])) ?>
@@ -33,7 +34,7 @@ include dirname(__DIR__).'/header.phtml';Möchten Sie ein Ticket für dieses Event kaufen?
Preis: = number_format($event['ticket_price'], 2, ',', '.') ?> €
- +