87 lines
3.2 KiB
PHP
87 lines
3.2 KiB
PHP
<?php
|
|
require 'config.php';
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
?>
|
|
<?php
|
|
// save-Logik
|
|
if (!empty($_POST)) { // $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
echo "<h3>Empfangene POST-Daten:</h3>";
|
|
echo "<ul>";
|
|
// Durch alle POST-Variablen iterieren
|
|
foreach ($_POST as $key => $value) {
|
|
// Wert escapen, um XSS zu vermeiden
|
|
$escapedValue = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
|
|
echo "<li><strong>$key:</strong> $escapedValue</li>";
|
|
}
|
|
echo "</ul>";
|
|
|
|
// POST-Daten abrufen und escapen
|
|
$date = isset($_POST['date']) ? trim($_POST['date']) : '';
|
|
$user_id = isset($_POST['user_id']) ? trim($_POST['user_id']) : '';
|
|
$category = isset($_POST['category']) ? trim($_POST['category']) : '';
|
|
$subject = isset($_POST['subject']) ? trim($_POST['subject']) : '';
|
|
$amount = isset($_POST['amount']) ? (float)$_POST['amount'] : 0.0;
|
|
$payment_method = isset($_POST['payment_method']) ? trim($_POST['payment_method']) : '';
|
|
|
|
// SQL-Statement vorbereiten
|
|
$stmt = $pdo->prepare("
|
|
INSERT INTO entries (date, user_id, category, subject, amount, payment_method)
|
|
VALUES (:date, :user_id, :category, :subject, :amount, :payment_method)
|
|
");
|
|
$stmt->bindParam(':date', $date);
|
|
$stmt->bindParam(':user_id', $date);
|
|
$stmt->bindParam(':category', $category);
|
|
$stmt->bindParam(':subject', $subject);
|
|
$stmt->bindParam(':amount', $amount);
|
|
$stmt->bindParam(':payment_method', $payment_method);
|
|
|
|
// Statement ausführen
|
|
$stmt->execute();
|
|
}
|
|
|
|
// Aktuelles Datum im Format YYYY-MM-DD erzeugen
|
|
$currentDate = date('Y-m-d');
|
|
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>FSCash - Neuer Eintrag</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="dashboard.php">Start</a></li>
|
|
<li><a href="register.php">Neue User</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>
|
|
|
|
<h1>Neuer Eintrag</h1>
|
|
<form action="new_entry.php" method="post">
|
|
<input type="date" name="date" value="<?php echo $currentDate; ?>" required>
|
|
<input type="text" name="user_id" required>
|
|
<input type="text" name="category" placeholder="Kategorie">
|
|
<input type="text" name="subject" placeholder="Betreff" required>
|
|
<input type="number" step="0.01" name="amount" placeholder="Betrag" required>
|
|
<input type="text" name="payment_method" placeholder="Zahlweise">
|
|
<button type="submit">Speichern</button>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|