File Manager V1.5
FILE_CONTENT: blog-post.php
<?php
include 'header.php';
require_once 'admin/functions.php';
if (!isset($_GET['id'])) {
header("Location: blog.php");
exit();
}
$post = getBlogPost($_GET['id']);
if (!$post || $post['status'] !== 'published') {
header("Location: blog.php");
exit();
}
$success_message = '';
$error_message = '';
// Handle feedback submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (addBlogFeedback($_POST)) {
$success_message = "Thank you for your feedback! It will be reviewed and published soon.";
} else {
$error_message = "Error submitting feedback. Please try again.";
}
}
// Get approved feedback for this post
$feedback = getBlogFeedback($post['id'], 'approved');
?>
<section class="blog-detail" style="margin-top:20%;">
<div class="auto-container">
<div class="inner-box">
<?php if ($post['image_url']): ?>
<div class="image">
<img src="<?php echo htmlspecialchars($post['image_url']); ?>"
alt="<?php echo htmlspecialchars($post['title']); ?>"
class="img-fluid">
</div>
<?php endif; ?>
<div class="lower-content">
<ul class="post-meta">
<li><span class="fa fa-calendar"></span><?php echo date('M j, Y', strtotime($post['created_at'])); ?></li>
<li><span class="fa fa-user"></span><?php echo htmlspecialchars($post['author']); ?></li>
</ul>
<h2><?php echo htmlspecialchars($post['title']); ?></h2>
<div class="text">
<?php echo $post['content']; ?>
</div>
</div>
</div>
<!-- Comments Section -->
<div class="comments-area">
<div class="group-title">
<h3>Feedback</h3>
</div>
<?php if ($feedback && $feedback->num_rows > 0): ?>
<?php while($comment = $feedback->fetch_assoc()): ?>
<div class="comment-box">
<div class="comment">
<div class="author-thumb">
<span class="fa fa-user-circle fa-3x"></span>
</div>
<div class="comment-info">
<strong><?php echo htmlspecialchars($comment['name']); ?></strong>
<div class="comment-time"><?php echo date('M j, Y', strtotime($comment['created_at'])); ?></div>
</div>
<div class="text"><?php echo nl2br(htmlspecialchars($comment['comment'])); ?></div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No feedback yet. Be the first to comment!</p>
<?php endif; ?>
</div>
<!-- Comment Form -->
<div class="comment-form">
<div class="group-title">
<h3>Leave Your Feedback</h3>
</div>
<?php if ($success_message): ?>
<div class="alert alert-success"><?php echo $success_message; ?></div>
<?php endif; ?>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<form method="post" id="feedback-form" style=" border:2px solid #2ed0b0; padding:20px;">
<input type="hidden" name="post_id" value="<?php echo $post['id']; ?>">
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<input type="text" name="name" placeholder="Your Name *" required>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<input type="email" name="email" placeholder="Your Email *" required>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
<textarea name="comment" placeholder="Your Feedback *" required></textarea>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
<button class="theme-btn btn-style-one" type="submit" name="submit-form">
<span class="txt">Submit Feedback</span>
</button>
</div>
</div>
</form>
</div>
</div>
</section>
<?php include 'footer.php'; ?>[ KEMBALI ]