"Zwischen-Views" erstellt für Weiterleitung nach Login/Logout. Views einheitlich im div container class="inhalt". Error message nach fehlerhaftem login.

This commit is contained in:
Karsten Tlotzek 2025-07-07 12:43:25 +02:00
parent b9fc6bcdd5
commit 3ce61ace17
12 changed files with 106 additions and 76 deletions

View File

@ -47,17 +47,17 @@ class AuthController
$password = $_POST['password'];
$result = $this->model->login($email, $password);
if ($result === true) {
$_SESSION['user'] = $email;
header('Location: /bibarts/?controller=News&do=showNews');
exit();
$_SESSION['user'] = $email;
$this->view->setDoMethodName('showLoginSuccess');
} else {
$this->view->setVars([
'errors' => ['login' => is_string($result) ? $result : "Login fehlgeschlagen."],
'validData' => ['email' => $email],
'loginSuccess' => false
]);
$this->view->setDoMethodName('showLoginForm');
}
}
@ -87,7 +87,6 @@ class AuthController
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
$this->view->setVars(['errors' => $errors, 'validData' => $data]);
$this->view->render('Auth/showRegistrationForm');
exit;
}
}
@ -128,8 +127,7 @@ class AuthController
}
}
public function showConfirmation()
{
public function showConfirmation() {
$messages = [
'login' => "Login erfolgreich.",
'register' => "Registrierung erfolgreich.",
@ -145,7 +143,6 @@ class AuthController
public function logout() {
unset($_SESSION['user']);
session_destroy();
header('Location: /bibarts/?controller=Auth&do=showLoginForm');
exit();
$this->view->setDoMethodName('showLogoutSuccess');
}
}

View File

@ -0,0 +1,15 @@
<div class="inhalt">
<div class="login-success">
<h2>Login erfolgreich!</h2>
<p>Sie werden in wenigen Sekunden zu den News weitergeleitet...</p>
</div>
</div>
<script>
setTimeout(function() {
window.location.href = "?controller=News&do=showNews";
}, 2000); // 2 Sekunden warten
</script>
<noscript>
<meta http-equiv="refresh" content="2;url=?controller=News&do=showNews">
</noscript>

View File

@ -0,0 +1,14 @@
<div class="inhalt">
<div class="login-success">
<h2>Logout erfolgreich!</h2>
<p>Sie werden in wenigen Sekunden zum Login weitergeleitet...</p>
</div>
</div>
<script>
setTimeout(function() {
window.location.href = "?controller=Auth&do=showLoginForm";
}, 2000); // 2 Sekunden warten
</script>
<noscript>
<meta http-equiv="refresh" content="2;url=?controller=Auth&do=showLoginForm">
</noscript>

View File

@ -2,11 +2,11 @@
include dirname(__DIR__).'/header.phtml';
?>
<div class="inhalt">
<div class="msg">
<p>Das Event "<?php echo $name?>" wurde erfolgreich erstellt!</p>
<a href="?controller=Event&do=showEvents">Weiter</a>
</div>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@ -2,11 +2,11 @@
include dirname(__DIR__).'/header.phtml';
?>
<div class="inhalt">
<div class="msg">
<p>Das Event mit der id"<?php echo $id?>" wurde erfolgreich gelöscht!</p>
<a href="?controller=Event&do=showEvents">Weiter</a>
</div>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@ -1,6 +1,3 @@
<?php if (!empty($events)): ?>
<div class="inhalt">
<div class="event-container">

View File

@ -2,11 +2,11 @@
include dirname(__DIR__).'/header.phtml';
?>
<div class="inhalt">
<div class="msg">
<p>Das Event mit der ID "<?php echo $ausstellungid?>" wurde erfolgreich bearbeitet!</p>
<a href="?controller=Event&do=showEvents">Weiter</a>
</div>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@ -1,5 +1,6 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<div class="inhalt">
<h2>Alle Gutscheine</h2>
<a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a>
<?php if (!empty($gutscheine)): ?>
@ -17,9 +18,9 @@
<?php foreach ($gutscheine as $g): ?>
<tr>
<td><?php echo htmlspecialchars($g['code']); ?></td>
<td><?php echo (int)$g['rabatt']; ?></td>
<td><?php echo (int)$g['eventid']; ?></td>
<td><?php echo htmlspecialchars($g['gültigkeit']); ?></td>
<td><?php echo (int)$g['discount']; ?></td>
<td><?php echo (int)$g['event_id']; ?></td>
<td><?php echo htmlspecialchars($g['valid_until']); ?></td>
<td>
<a href="?controller=Gutschein&action=editGutscheinForm&id=<?php echo $g['gutscheinid']; ?>">Bearbeiten</a> |
<a href="?controller=Gutschein&action=deleteGutschein&id=<?php echo $g['gutscheinid']; ?>" onclick="return confirm('Wirklich löschen?');">Löschen</a>
@ -31,5 +32,5 @@
<?php else: ?>
<p>Keine Gutscheine vorhanden.</p>
<?php endif; ?>
</div>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>

View File

@ -1,8 +1,7 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<h2>Alle News</h2>
<?php if (!empty($news)): ?>
<div class="inhalt">
<table>
<thead>
<tr>
@ -15,14 +14,14 @@
<?php foreach ($news as $item): ?>
<tr>
<td><?php echo htmlspecialchars($item['name']); ?></td>
<td><?php echo nl2br(htmlspecialchars($item['beschreibung'])); ?></td>
<td><?php echo date('d.m.Y', strtotime($item['datum'])); ?></td>
<td><?php echo nl2br(htmlspecialchars($item['name'])); ?></td>
<td><?php echo nl2br(htmlspecialchars($item['description'])); ?></td>
<td><?php echo date('d.m.Y', strtotime($item['date'])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<p>Derzeit sind keine News verfügbar.</p>
<?php endif; ?>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
<?php endif; ?>

View File

@ -1,5 +1,6 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<div class="inhalt">
<h2>Unsere Standorte</h2>
<?php if (!empty($standorte)): ?>
@ -18,12 +19,12 @@
<tbody>
<?php foreach ($standorte as $standort): ?>
<tr>
<td><?php echo htmlspecialchars($standort['stre']); ?></td>
<td><?php echo htmlspecialchars($standort['hausnr']); ?></td>
<td><?php echo htmlspecialchars($standort['postleitzahl']); ?></td>
<td><?php echo htmlspecialchars($standort['ort']); ?></td>
<td><?php echo htmlspecialchars($standort['land']); ?></td>
<td><?php echo htmlspecialchars($standort['tel']); ?></td>
<td><?php echo htmlspecialchars($standort['street']); ?></td>
<td><?php echo htmlspecialchars($standort['house_number']); ?></td>
<td><?php echo htmlspecialchars($standort['postal_code']); ?></td>
<td><?php echo htmlspecialchars($standort['city']); ?></td>
<td><?php echo htmlspecialchars($standort['country']); ?></td>
<td><?php echo htmlspecialchars($standort['phone']); ?></td>
<td><?php echo htmlspecialchars($standort['email']); ?></td>
</tr>
<?php endforeach; ?>
@ -32,5 +33,5 @@
<?php else: ?>
<p>Keine Standorte gefunden.</p>
<?php endif; ?>
</div>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>

View File

@ -15,7 +15,15 @@
<a id="link-tickets" class="links" href="?controller=Event&do=showEvents">Event</a>
<a id="link-infos" class="links" href="?controller=Welcome&do=showWelcome">Infos</a>
<a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a>
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a>
<?php if (isset($_SESSION['user'])): ?>
<form method="post" action="index.php" style="display:inline;">
<input type="hidden" name="controller" value="Auth">
<input type="hidden" name="do" value="logout">
<button type="submit" class="links" style="background:none;border:none;cursor:pointer;">Logout</button>
</form>
<?php else: ?>
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a>
<?php endif; ?>
<a id="link-register" class="links" href="?controller=Auth&do=showRegistrationForm">Register</a>
<div id="profile-picture"></div>
</div>

View File

@ -2,48 +2,46 @@
session_start();
include 'Views/header.phtml';
?>
<div id="wrapper">
<?php
spl_autoload_register(function ($className) {
if (substr($className, 0, 5) !== 'Blog\\') {
// not our business
return;
}
$fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 5)).'.php';
if (file_exists($fileName)) {
include $fileName;
}
});
$controllerName = "";
$doMethodName = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$controllerName = isset($_POST['controller']) && $_POST['controller'] ? $_POST['controller'] : "Welcome";
$doMethodName = isset($_POST['do']) && $_POST['do'] ? $_POST['do'] : "showWelcome";
} else {
$controllerName = isset($_GET['controller']) && $_GET['controller'] ? $_GET['controller'] : "Welcome";
$doMethodName = isset($_GET['do']) && $_GET['do'] ? $_GET['do'] : "showWelcome";
<?php
spl_autoload_register(function ($className) {
if (substr($className, 0, 5) !== 'Blog\\') {
// not our business
return;
}
$controllerClassName = 'Blog\\Controller\\'.ucfirst($controllerName).'Controller';
$fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 5)).'.php';
if (method_exists($controllerClassName, $doMethodName)) {
$view = new \Blog\Library\View(__DIR__.DIRECTORY_SEPARATOR.'Views'
, ucfirst($controllerName), $doMethodName);
$controller = new $controllerClassName($view);
$controller->$doMethodName();
$view->render();
} else {
new \Blog\Library\ErrorMsg('Page not found: '.$controllerClassName.'::'.$doMethodName);
if (file_exists($fileName)) {
include $fileName;
}
?>
</div>
});
$controllerName = "";
$doMethodName = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$controllerName = isset($_POST['controller']) && $_POST['controller'] ? $_POST['controller'] : "Welcome";
$doMethodName = isset($_POST['do']) && $_POST['do'] ? $_POST['do'] : "showWelcome";
} else {
$controllerName = isset($_GET['controller']) && $_GET['controller'] ? $_GET['controller'] : "Welcome";
$doMethodName = isset($_GET['do']) && $_GET['do'] ? $_GET['do'] : "showWelcome";
}
$controllerClassName = 'Blog\\Controller\\'.ucfirst($controllerName).'Controller';
if (method_exists($controllerClassName, $doMethodName)) {
$view = new \Blog\Library\View(__DIR__.DIRECTORY_SEPARATOR.'Views'
, ucfirst($controllerName), $doMethodName);
$controller = new $controllerClassName($view);
$controller->$doMethodName();
$view->render();
} else {
new \Blog\Library\ErrorMsg('Page not found: '.$controllerClassName.'::'.$doMethodName);
}
?>
<?php
include 'Views/footer.phtml';
?>