diff($date1)->days; // Determine rate per night $rate_per_night = ($is_member) ? 0 : 200; // Free for members, R200 for non-members // Calculate the total cost $vehicle_cost = $rate_per_night * $num_vehicles * $nights; $firewood_cost = $add_firewood ? 50 : 0; $total_amount = $vehicle_cost + $firewood_cost; // Calculate discount if the user is a member $discount_amount = ($is_member) ? $vehicle_cost : 0; // Insert booking into the database $sql = "INSERT INTO bookings (booking_type, user_id, from_date, to_date, num_vehicles, num_adults, num_children, add_firewood, total_amount, discount_amount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param('sissiiiidd', $type, $user_id, $from_date, $to_date, $num_vehicles, $num_adults, $num_children, $add_firewood, $total_amount, $discount_amount); if ($stmt->execute()) { // Redirect to success page or display success message echo ""; } else { // Handle error if insert fails echo ""; } $stmt->close(); $conn->close(); } else { echo "Invalid request."; } ?>