Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Guestbook</title>
<link rel="stylesheet" href="style.css">
</head>
<?php
$error = null;
if(isset($_GET['error'])) {
$error = $_GET['error'];
$message = $_GET['message'];
echo "<script>alert('Error: " . $message . "')</script>";
}
?>
<body>
<div class="container">
<!-- Navbar -->
<div class="navbar">
<a href="index.php">Home</a>
<a href="form.php">Enter Guestbook</a>
</div>
<!-- Title -->
<div class="title">
<h1>Guestbook</h1>
</div>
<!-- Display Guestbook Entries -->
<div class="entries">
<?php
// Include the database connection file
require_once('connection.php');
try {
// Select data from the guestbook table
$stmt = $pdo->prepare("SELECT * FROM guestbook ORDER BY gasten_datum DESC");
$stmt->execute();
// Fetch all rows as an associative array
$guestbookEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Process and display the retrieved data
foreach ($guestbookEntries as $entry) {
// Format the date for display
$submissionTimeFormatted = date("d M Y H:i", strtotime($entry['gasten_datum']));
echo "<div class='entry'>";
echo "<p><strong>{$entry['gasten_naam']}:</strong> {$entry['gasten_bericht']}</p>";
// Check if there is an image uploaded
if (!empty($entry['gasten_foto'])) {
// Display image if an image is uploaded
echo "<p><img src='{$entry['gasten_foto']}' alt='Uploaded Image'></p>";
}
echo "<p>{$submissionTimeFormatted}</p>"; // Display formatted datetime
echo "<hr class='lijn'>";
echo "</div>";
}
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
?>
</div>
</div>
</body>
</html>