1e versie
This commit is contained in:
34
public/wishlist.php
Normal file
34
public/wishlist.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/../includes/db.php';
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$gebruiker = $_SESSION['user'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$wensen = $_POST['wensen'] ?? '';
|
||||
$stmt = $pdo->prepare("REPLACE INTO wishlists (user, wensen) VALUES (?, ?)");
|
||||
$stmt->execute([$gebruiker, $wensen]);
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT wensen FROM wishlists WHERE user = ?");
|
||||
$stmt->execute([$gebruiker]);
|
||||
$wensen = $stmt->fetchColumn();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Verlanglijstje</title></head>
|
||||
<body>
|
||||
<h2>Mijn verlanglijstje</h2>
|
||||
<form method="post">
|
||||
<textarea name="wensen" rows="8" cols="40"><?= htmlspecialchars($wensen ?? '') ?></textarea><br>
|
||||
<button type="submit">Opslaan</button>
|
||||
</form>
|
||||
<p><a href="dashboard.php">Terug</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user