beginTransaction(); $stmt = $pdo->prepare("INSERT INTO bookings (user_id, car_id, status) VALUES (?, ?, 'pending')"); $stmt->execute([$userId, $carId]); $stmt = $pdo->prepare("UPDATE cars SET status = 'reserved' WHERE id = ? AND status = 'approved'"); $stmt->execute([$carId]); $pdo->commit(); $message = "Your booking request has been sent! The car is reserved for you pending admin approval."; $message_type = 'success'; } catch (Exception $e) { $pdo->rollBack(); error_log("Booking failed: " . $e->getMessage()); $message = "There was an error processing your booking. Please try again."; $message_type = 'danger'; } } // Review Logic if (isset($_POST['submit_review'])) { $rating = filter_input(INPUT_POST, 'rating', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 5]]); $review_text = trim(filter_input(INPUT_POST, 'review', FILTER_SANITIZE_SPECIAL_CHARS)); if ($rating && !empty($review_text)) { $stmt = $pdo->prepare("INSERT INTO reviews (car_id, user_id, rating, review) VALUES (?, ?, ?, ?)"); $stmt->execute([$carId, $userId, $rating, $review_text]); $message = "Your review has been submitted and is pending approval."; $message_type = 'success'; } else { $message = "Invalid rating or review text."; $message_type = 'danger'; } } } // Fetch car details $stmt = $pdo->prepare("SELECT * FROM cars WHERE id = ?"); $stmt->execute([$carId]); $car = $stmt->fetch(PDO::FETCH_ASSOC); if (!$car) { header("Location: car_list.php"); exit(); } // Fetch approved reviews $stmt = $pdo->prepare("SELECT r.*, u.username FROM reviews r JOIN users u ON r.user_id = u.id WHERE r.car_id = ? AND r.status = 'approved' ORDER BY r.created_at DESC"); $stmt->execute([$carId]); $reviews = $stmt->fetchAll(PDO::FETCH_ASSOC); $projectName = htmlspecialchars($car['make'] . ' ' . $car['model']); ?> <?= $projectName ?> - Car Sells Afghanistan
<?= $projectName ?>

Key Specifications

Year:
Color:
Mileage: km
Fuel: Petrol
$
This car is currently and cannot be booked.

Customer Reviews

Leave Your Feedback

Log in to share your experience.

Be the first to write a review for this car!