<?php
require_once __DIR__ . '/../../connect.php';

// جلب البيانات من الطلب
$driver_name   = filterRequest("driver_name");
$national_id   = filterRequest("national_id");
$birth_date    = filterRequest("birth_date");
$license_type  = filterRequest("license_type");
$phone         = filterRequest("phone");
$site          = filterRequest("site");

// إعداد استعلام آمن باستخدام bind parameters
$sql = "INSERT INTO `driversWantWork`(
    `driver_name`,
    `phone`,
    `national_id`,
    `birth_date`,
    `license_type`,
    `site`
) VALUES (
    :driver_name,
    :phone,
    :national_id,
    :birth_date,
    :license_type,
    :site
)";

$stmt = $con->prepare($sql);

// ربط القيم
$stmt->bindParam(':driver_name', $driver_name);
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':national_id', $national_id);
$stmt->bindParam(':birth_date', $birth_date);
$stmt->bindParam(':license_type', $license_type);
$stmt->bindParam(':site', $site);

// تنفيذ الاستعلام
if ($stmt->execute()) {
    jsonSuccess(null, "Driver data saved successfully");
} else {
    jsonError("Failed to save driver data");
}
?>