pdo(); $userId = $_SESSION['user_id'] ?? null; $id = (int)($_GET['id'] ?? 0); $error = ''; if (!$id) { http_response_code(404); exit('

Thread nicht gefunden.

'); } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'reply') { if (!$userId) { $error = 'Bitte einloggen, um zu antworten.'; } elseif ($pdo) { $body = trim((string)($_POST['body'] ?? '')); if ($body === '') { $error = 'Antwort darf nicht leer sein.'; } else { $pdo->prepare('INSERT INTO forum_posts (thread_id, user_id, body) VALUES (:tid, :uid, :body)') ->execute(['tid' => $id, 'uid' => $userId, 'body' => $body]); header('Location: /community_thread?id=' . $id); exit; } } } $thread = null; $posts = []; if ($pdo) { $stmt = $pdo->prepare('SELECT ft.*, p.display_name FROM forum_threads ft LEFT JOIN user_profiles p ON p.user_id = ft.user_id WHERE ft.id = :id'); $stmt->execute(['id' => $id]); $thread = $stmt->fetch(PDO::FETCH_ASSOC); if ($thread) { $stmt = $pdo->prepare('SELECT fp.*, p.display_name FROM forum_posts fp LEFT JOIN user_profiles p ON p.user_id = fp.user_id WHERE fp.thread_id = :id ORDER BY fp.created_at ASC'); $stmt->execute(['id' => $id]); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: []; } } if (!$thread) { http_response_code(404); exit('

Thread nicht gefunden.

'); } ?>

Community

Von ยท

Antworten ()

Noch keine Antworten.

Bitte einloggen, um zu antworten.