66 lines
2.5 KiB
PHP
66 lines
2.5 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
require_once '../db/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->query("SELECT id, name, email, message, created_at FROM contact_submissions ORDER BY created_at DESC");
|
|
$submissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
// For development, you might want to log this error.
|
|
// For production, show a generic error message.
|
|
die("Could not connect to the database. Please try again later.");
|
|
}
|
|
|
|
include 'header.php';
|
|
?>
|
|
|
|
<div class="container-fluid">
|
|
<h1 class="h3 mb-4 text-gray-800">Contact Form Submissions</h1>
|
|
|
|
<div class="card shadow mb-4">
|
|
<div class="card-header py-3">
|
|
<h6 class="m-0 font-weight-bold text-primary">Received Messages</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Name</th>
|
|
<th>Email</th>
|
|
<th>Message</th>
|
|
<th>Received At</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($submissions)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center">No submissions yet.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($submissions as $submission): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($submission['id']); ?></td>
|
|
<td><?php echo htmlspecialchars($submission['name']); ?></td>
|
|
<td><a href="mailto:<?php echo htmlspecialchars($submission['email']); ?>"><?php echo htmlspecialchars($submission['email']); ?></a></td>
|
|
<td><?php echo nl2br(htmlspecialchars($submission['message'])); ?></td>
|
|
<td><?php echo htmlspecialchars($submission['created_at']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include 'footer.php'; ?>
|