prepare("SELECT b.*, u.username FROM books b JOIN users u ON b.user_id = u.id WHERE b.id = ?"); $stmt->execute([$book_id]); $book = $stmt->fetch(); if (!$book) { // Redirect if book doesn't exist header("Location: index.php"); exit; } ?>