83 lines
2.7 KiB
PHP
83 lines
2.7 KiB
PHP
<?php
|
|
require 'config.php';
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
// Login-Logik
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
|
|
$stmt->execute([$_POST['username']]);
|
|
$user = $stmt->fetch();
|
|
if ($user && password_verify($_POST['password'], $user['password'])) {
|
|
$_SESSION['user_id'] = $user['id'];
|
|
} else {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Daten abrufen
|
|
$stmt = $pdo->prepare("SELECT * FROM entries WHERE user_id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$entries = $stmt->fetchAll();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>FinanzApp - Dashboard</title>
|
|
<link rel="stylesheet" href="assets/css/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- Navigation -->
|
|
<nav class="nav">
|
|
<button class="hamburger">☰</button>
|
|
<ul class="nav-list">
|
|
<li><a href="menu1.php">Menüpunkt 1</a></li>
|
|
<li><a href="menu2.php">Menüpunkt 2</a></li>
|
|
<li><a href="menu3.php">Menüpunkt 3</a></li>
|
|
<li><a href="menu4.php">Menüpunkt 4</a></li>
|
|
<li><a href="menu5.php">Menüpunkt 5</a></li>
|
|
</ul>
|
|
<a href="logout.php" class="logout">Logout</a>
|
|
</nav>
|
|
|
|
<!-- Tabelle -->
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Datum</th>
|
|
<?php if (!isset($_COOKIE['mobile'])): ?>
|
|
<th>Kategorie</th>
|
|
<th>Zahlweise</th>
|
|
<?php endif; ?>
|
|
<th>Betreff</th>
|
|
<th>Betrag</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($entries as $entry): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($entry['date']) ?></td>
|
|
<?php if (!isset($_COOKIE['mobile'])): ?>
|
|
<td><?= htmlspecialchars($entry['category'] ?? '') ?></td>
|
|
<td><?= htmlspecialchars($entry['payment_method'] ?? '') ?></td>
|
|
<?php endif; ?>
|
|
<td><?= htmlspecialchars($entry['subject']) ?></td>
|
|
<td><?= htmlspecialchars($entry['amount']) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- Neu-Button -->
|
|
<a href="new_entry.php" class="btn-new">Neu</a>
|
|
</div>
|
|
|
|
<script src="assets/js/script.js"></script>
|
|
</body>
|
|
</html>
|