����JFIF��`�`�����Viewing File: /home/u820193700/domains/throtllr.in/public_html/api/submit_inspection.php
<?php
require_once '../includes/db.php';
require_once '../includes/functions.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (!isset($_POST['csrf_token']) || !verify_csrf_token($_POST['csrf_token'])) {
        die("CSRF token validation failed.");
    }
    $bike_id = !empty($_POST['bike_id']) ? intval($_POST['bike_id']) : null;
    $name = $_POST['name'] ?? '';
    $phone = $_POST['phone'] ?? '';
    $preferred_date = $_POST['preferred_date'] ?? '';
    $preferred_time = $_POST['preferred_time'] ?? null;
    // Handle empty time properly for MySQL TIME column
    if (empty($preferred_time)) {
        $preferred_time = null;
    }
    $address = $_POST['address'] ?? '';
    $notes = $_POST['notes'] ?? '';

    try {
        $customer_id = $_SESSION['customer_id'] ?? null;
        $stmt = $pdo->prepare("INSERT INTO inspection_bookings (bike_id, customer_id, name, phone, preferred_date, preferred_time, address, additional_notes, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'pending')");
        $stmt->execute([
            $bike_id, $customer_id, $name, $phone, $preferred_date, $preferred_time, $address, $notes
        ]);

        header("Location: ../book-inspection.php?success=1");
        exit;
    } catch (\PDOException $e) {
        die("Database error: " . $e->getMessage());
    }
} else {
    header("Location: ../book-inspection.php");
    exit;
}
?>
Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����