Design angepasst
This commit is contained in:
@@ -3,10 +3,10 @@ session_start();
|
||||
|
||||
require_once '../inc/header.php'; ?>
|
||||
|
||||
<div class="container">
|
||||
<h1 class="mb-4">Debug-Informationen</h1>
|
||||
<div class="container mt-5">
|
||||
<h2 class="mb-4">Debug-Informationen</h2>
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h4>Session-Daten ($_SESSION)</h4>
|
||||
</div>
|
||||
@@ -19,7 +19,7 @@ require_once '../inc/header.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-success text-white">
|
||||
<h4>Cookie-Daten ($_COOKIE)</h4>
|
||||
</div>
|
||||
|
||||
@@ -135,7 +135,7 @@ require_once '../inc/header.php';
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Hex-Code</th>
|
||||
<th>Vorschau</th>
|
||||
<th>Farbe</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
118
admin/users.php
118
admin/users.php
@@ -7,8 +7,10 @@ if ($_SESSION['role'] !== 'admin') {
|
||||
die("Zugriff nur für Admins");
|
||||
}
|
||||
|
||||
// Datenbankverbindung einbinden
|
||||
|
||||
$message = '';
|
||||
$message_type = '';
|
||||
$edit_mode = false;
|
||||
$edit_user = null;
|
||||
|
||||
// Benutzer hinzufügen
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['username'], $_POST['password'], $_POST['role'])) {
|
||||
@@ -19,8 +21,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['username'], $_POST['pa
|
||||
$sql = "INSERT INTO users (username, password, role) VALUES ('$username', '$password', '$role')";
|
||||
if (mysqli_query($conn, $sql)) {
|
||||
$message = "Benutzer erfolgreich hinzugefügt.";
|
||||
$message_type = 'success';
|
||||
} else {
|
||||
$message = "Fehler beim Hinzufügen: " . mysqli_error($conn);
|
||||
$message_type = 'danger';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,39 +37,91 @@ if ($result) {
|
||||
}
|
||||
}
|
||||
|
||||
require_once '../inc/header.php';
|
||||
require_once('../inc/header.php');
|
||||
?>
|
||||
|
||||
<h1>Benutzerverwaltung</h1>
|
||||
<div class="container mt-5">
|
||||
<h2 class="mb-4">Benutzerverwaltung</h2>
|
||||
|
||||
<?php if (isset($message)) echo "<p><strong>$message</strong></p>"; ?>
|
||||
<?php if ($message) : ?>
|
||||
<div id="status-message" class="alert alert-<?php echo $message_type; ?> alert-dismissible fade show" role="alert">
|
||||
<?php echo htmlspecialchars($message); ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post">
|
||||
<label>Benutzername: <input type="text" name="username" required></label><br>
|
||||
<label>Passwort: <input type="password" name="password" required></label><br>
|
||||
<label>Rolle:
|
||||
<select name="role">
|
||||
<option value="member">Mitglied</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select>
|
||||
</label><br>
|
||||
<button type="submit">Benutzer hinzufügen</button>
|
||||
</form>
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h4 class="mb-0">Neuen Benutzer hinzufügen</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-4">
|
||||
<label for="username" class="form-label">Benutzername</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
<div class="form-text" style="visibility: hidden;"> </div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="password" class="form-label">Passwort</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
<div class="form-text" style="visibility: hidden;"> </div>
|
||||
</div>
|
||||
<div class="col-md-4 d-flex flex-column justify-content-end">
|
||||
<label for="role" class="form-label">Rolle</label>
|
||||
<div class="d-flex w-100">
|
||||
<select class="form-select w-100" id="role" name="role">
|
||||
<option value="member">Mitglied</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select>
|
||||
|
||||
<h2>Benutzerübersicht</h2>
|
||||
<table border="1" cellpadding="5">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Benutzername</th>
|
||||
<th>Rolle</th>
|
||||
</tr>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($user['id']) ?></td>
|
||||
<td><?= htmlspecialchars($user['username']) ?></td>
|
||||
<td><?= htmlspecialchars($user['role']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div><button type="submit" class="btn btn-primary ms-2">Hinzufügen</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-secondary text-white">
|
||||
<h4 class="mb-0">Benutzerübersicht</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Benutzername</th>
|
||||
<th>Rolle</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($user['id']) ?></td>
|
||||
<td><?= htmlspecialchars($user['username']) ?></td>
|
||||
<td>
|
||||
<span class="badge rounded-pill bg-<?= $user['role'] === 'admin' ? 'info' : 'secondary' ?>">
|
||||
<?= htmlspecialchars($user['role']) ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="text-dark me-1 text-decoration-none" data-bs-toggle="tooltip" data-bs-placement="top" title="Bearbeiten">
|
||||
<span class="material-icons">mode_edit_outline</span>
|
||||
</a>
|
||||
<a href="#" class="text-danger text-decoration-none" data-bs-toggle="tooltip" data-bs-placement="top" title="Löschen">
|
||||
<span class="material-icons">delete_outline</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('../inc/footer.php'); ?>
|
||||
Reference in New Issue
Block a user