<?php
header('Content-Type: application/json');

include '../db.php';

$user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0;

if ($user_id <= 0) {
    echo json_encode(['error' => 'Invalid user ID']);
    exit();
}

$sql = "SELECT *, driver_name, phone, driver_address, driver_email, vehicle_type, vehicle_number 
        FROM registered_vehicles 
        WHERE id = $user_id";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $user = $result->fetch_assoc();
    echo json_encode($user);
} else {
    echo json_encode(['error' => 'User not found']);
}

$conn->close();
?>
