53 lines
1.3 KiB
PHP
Executable File
53 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['uid'])) {
|
|
header('Location: /admin/login.php');
|
|
die;
|
|
}
|
|
|
|
$id = $_GET['id'];
|
|
if (!isset($id)) {
|
|
http_response_code(400);
|
|
die("No message ID provided.");
|
|
}
|
|
|
|
$conn = new mysqli("localhost", "mileslinden", "Daiso@6969", "mileslinden");
|
|
|
|
$query = $conn->prepare("SELECT * FROM messages WHERE id = ?");
|
|
if (!$query) {
|
|
http_response_code(500);
|
|
die("Error: {$conn->error}");
|
|
}
|
|
if (!$query->bind_param("i", $id)) {
|
|
http_response_code(400);
|
|
die("Message ID must be an integer.");
|
|
}
|
|
if (!$query->execute()) {
|
|
http_response_code(500);
|
|
die("Error {$query->errno}: {$query->error}");
|
|
}
|
|
|
|
$result = $query->get_result();
|
|
if ($result->num_rows === 0) {
|
|
http_response_code(404);
|
|
die("Message with ID $id not found.");
|
|
}
|
|
|
|
$message = $result->fetch_assoc();
|
|
?>
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Miles Linden for San Jose City Council</title>
|
|
</head>
|
|
<body>
|
|
<h1><?= isset($message['subject']) ? htmlspecialchars($message['subject']) : '(no subject)' ?></h1>
|
|
<p>From: <?= htmlspecialchars($message['full_name']) ?> (<a href="mailto:<?= htmlspecialchars($message['email']) ?>"><?= htmlspecialchars($message['email']) ?></a>)</p>
|
|
<p>Date: <strong><?= $message['send_date'] ?></strong></p>
|
|
<pre><?= htmlspecialchars($message['message']) ?></pre>
|
|
</body>
|
|
</html>
|