26 lines
No EOL
1,020 B
PHP
26 lines
No EOL
1,020 B
PHP
<?php
|
|
class Flash {
|
|
// Nachricht setzen (Typ: 'error', 'success', 'warning', 'info')
|
|
public static function set($message, $type = 'error') {
|
|
$_SESSION['flash_messages'][] = [
|
|
'message' => $message,
|
|
'type' => $type
|
|
];
|
|
}
|
|
|
|
// Nachrichten ausgeben und danach löschen
|
|
public static function display() {
|
|
if (isset($_SESSION['flash_messages'])) {
|
|
foreach ($_SESSION['flash_messages'] as $flash) {
|
|
// Farben je nach Typ
|
|
$color = $flash['type'] === 'error' ? 'red' : 'emerald';
|
|
|
|
echo "<div class='fixed top-4 right-4 bg-{$color}-500/10 border border-{$color}-500/30 text-{$color}-400 px-6 py-3 rounded-lg shadow-lg backdrop-blur-sm z-50 animate-bounce'>
|
|
" . htmlspecialchars($flash['message']) . "
|
|
</div>";
|
|
}
|
|
// Nach dem Anzeigen direkt aufräumen!
|
|
unset($_SESSION['flash_messages']);
|
|
}
|
|
}
|
|
} |