Posted on
prepare("SELECT * FROM posts WHERE id = ?"); $stmt->execute([$post_id]); $post = $stmt->fetch(); } catch (PDOException $e) { error_log("DB Error: " . $e->getMessage()); } // If no post is found, redirect to the homepage if (!$post) { header("Location: index.php"); exit; } ?>