34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM posts WHERE id = ?");
|
|
$stmt->execute([$_GET['id'] ?? 0]);
|
|
$post = $stmt->fetch();
|
|
|
|
if (!$post) {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
$page_title = htmlspecialchars($post['title']);
|
|
$page_description = htmlspecialchars(substr($post['content'], 0, 160));
|
|
|
|
include 'header.php';
|
|
?>
|
|
|
|
<div class="row">
|
|
<div class="col-md-8 offset-md-2">
|
|
<div class="card post-card">
|
|
<div class="card-body">
|
|
<h1 class="card-title post-title"><?php echo htmlspecialchars($post['title']); ?></h1>
|
|
<p class="text-muted">By <?php echo htmlspecialchars($post['author']); ?> on <?php echo date("F j, Y", strtotime($post['created_at'])); ?></p>
|
|
<p class="card-text"><?php echo nl2br(htmlspecialchars($post['content'])); ?></p>
|
|
</div>
|
|
</div>
|
|
<a href="index.php" class="btn btn-secondary mt-3"><i class="bi bi-arrow-left"></i> Back to Home</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php include 'footer.php'; ?>
|