<?php
include 'db.php';

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$vehicle = $_POST['vehicle_number'];
$is_active = isset($_POST['is_active']) ? 1 : 0;

$stmt = $conn->prepare("INSERT INTO delivery_riders (name, phone, email, vehicle_number, is_active) VALUES (?, ?, ?, ?, ?)");
$stmt->bind_param("ssssi", $name, $phone, $email, $vehicle, $is_active);

if ($stmt->execute()) {
    header("Location: rider_list.php?success=1");
} else {
    echo "Error: " . $conn->error;
}
