40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
require_once 'header.php';
|
|
|
|
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare("SELECT * FROM posts WHERE id = ?");
|
|
$stmt->execute([$_GET['id']]);
|
|
$post = $stmt->fetch();
|
|
|
|
if (!$post) {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
?>
|
|
|
|
<div class="row g-5">
|
|
<div class="col-md-8">
|
|
<article class="blog-post">
|
|
<h2 class="blog-post-title"><?php echo htmlspecialchars($post['title']); ?></h2>
|
|
<p class="blog-post-meta"><?php echo date('F j, Y', strtotime($post['created_at'])); ?> by <a href="#"><?php echo htmlspecialchars($post['author']); ?></a></p>
|
|
<div class="post-content">
|
|
<?php echo nl2br(htmlspecialchars($post['content'])); ?>
|
|
</div>
|
|
</article>
|
|
<a href="index.php" class="btn btn-secondary mt-4">Back to Posts</a>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="position-sticky" style="top: 2rem;">
|
|
<div class="p-4 mb-3 bg-light rounded">
|
|
<h4 class="fst-italic">About</h4>
|
|
<p class="mb-0">This is a simple blog created with PHP and Bootstrap. You can find articles about web development, productivity, and more.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'footer.php'; ?>
|