prepare("SELECT * FROM bookings WHERE id = ? AND client_id = ? AND status = 'completed'"); $stmt->execute([$booking_id, $client_id]); $booking = $stmt->fetch(); if (!$booking) { header('Location: dashboard.php?status=error'); exit; } // Check if already reviewed $stmt = db()->prepare("SELECT id FROM reviews WHERE booking_id = ?"); $stmt->execute([$booking_id]); if ($stmt->fetch()) { header('Location: dashboard.php?status=already_reviewed'); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $rating = $_POST['rating'] ?? null; $review = $_POST['review'] ?? null; $coach_id = $booking['coach_id']; if ($rating && $rating >= 1 && $rating <= 5) { $stmt = db()->prepare("INSERT INTO reviews (booking_id, coach_id, client_id, rating, review) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$booking_id, $coach_id, $client_id, $rating, $review]); header('Location: dashboard.php?status=review_success'); exit; } else { $error = "Please select a rating between 1 and 5."; } } ?> Review Booking - CoachConnect

Review Your Session