fixed redirect error and added button to events.

This commit is contained in:
Viktor Sergeev 2025-07-11 23:09:17 +02:00
parent f780888107
commit 906ca76332
4 changed files with 14 additions and 22 deletions

View File

@ -20,8 +20,7 @@ class TicketController {
public function showTickets() {
if (!isset($_SESSION['user_id'])) {
$this->view->setVars(['error' => 'Bitte melden Sie sich an, um Ihre Tickets zu sehen.']);
$this->view->setDoMethodName('showLoginForm');
$this->view->setVars(['redirect' => 'index.php?controller=Auth&do=showLoginForm']);
return;
}
@ -31,22 +30,19 @@ class TicketController {
public function showBuyTicketForm() {
if (!isset($_SESSION['user_id'])) {
$this->view->setVars(['error' => 'Bitte melden Sie sich an, um Tickets zu kaufen.']);
$this->view->setDoMethodName('showLoginForm');
$this->view->setVars(['redirect' => 'index.php?controller=Auth&do=showLoginForm']);
return;
}
$event_id = $_GET['event_id'] ?? null;
if (!$event_id) {
$this->view->setVars(['error' => 'Keine Event-ID angegeben.']);
$this->view->setDoMethodName('showEvents');
$this->view->setVars(['redirect' => 'index.php?controller=Event&do=showEvents']);
return;
}
$event = $this->eventModel->getEvent($event_id);
if (!$event) {
$this->view->setVars(['error' => 'Event nicht gefunden.']);
$this->view->setDoMethodName('showEvents');
$this->view->setVars(['redirect' => 'index.php?controller=Event&do=showEvents']);
return;
}
@ -111,8 +107,7 @@ class TicketController {
public function deleteTicket() {
if (!isset($_SESSION['user_id'])) {
$this->view->setVars(['error' => 'Bitte melden Sie sich an.']);
$this->view->setDoMethodName('showLoginForm');
$this->view->setVars(['redirect' => 'index.php?controller=Auth&do=showLoginForm']);
return;
}

View File

@ -7,6 +7,13 @@
<a href="?controller=Event&do=showCreateEvent" class="admin-btn">Event erstellen</a>
<?php endif; ?>
</div>
<?php if (!isset($_SESSION['user_id'])): ?>
<div class="status-box" style="margin-bottom: 20px;">
<p>Bitte <a href="?controller=Auth&do=showLoginForm">melden Sie sich an</a>, um Tickets zu kaufen.</p>
</div>
<?php endif; ?>
<div class="event-container-inhalt">
<table>
<thead>

View File

@ -6,12 +6,7 @@ include dirname(__DIR__).'/header.phtml';
<div class="form-container">
<h1>Ticket kaufen</h1>
<?php if (isset($error)): ?>
<div class="error-box"><?= htmlspecialchars($error) ?></div>
<div style="text-align:center; margin-top: 1.5em;">
<a href="?controller=Event&do=showEvents">Zurück zu den Events</a>
</div>
<?php elseif (isset($event)): ?>
<?php if (isset($event)): ?>
<div class="event-details">
<h2><?= htmlspecialchars($event['name']) ?></h2>
<p><strong>Beschreibung:</strong> <?= nl2br(htmlspecialchars($event['description'])) ?></p>

View File

@ -8,12 +8,7 @@ include dirname(__DIR__).'/header.phtml';
<h2>Meine Tickets</h2>
</div>
<?php if (isset($error)): ?>
<div class="error-box"><?= htmlspecialchars($error) ?></div>
<div style="text-align:center; margin-top: 1.5em;">
<a href="?controller=Auth&do=showLoginForm">Zum Login</a>
</div>
<?php elseif (!empty($tickets)): ?>
<?php if (!empty($tickets)): ?>
<div class="event-container-inhalt">
<table>
<thead>