35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
// Sanitize and validate input
|
|
$driverId = filterRequest("driverId");
|
|
$issueDate = filterRequest("IssueDate");
|
|
$inspectionResult = filterRequest("InspectionResult");
|
|
|
|
// Prepare SQL statement
|
|
$sql = "INSERT INTO criminalDocuments (driverId, IssueDate, InspectionResult)
|
|
VALUES (:driverId, :issueDate, :inspectionResult)";
|
|
|
|
try {
|
|
$stmt = $con->prepare($sql);
|
|
|
|
// Bind parameters
|
|
$stmt->bindParam(':driverId', $driverId, PDO::PARAM_INT);
|
|
$stmt->bindParam(':issueDate', $issueDate, PDO::PARAM_STR);
|
|
$stmt->bindParam(':inspectionResult', $inspectionResult, PDO::PARAM_STR);
|
|
|
|
// Execute the statement
|
|
$stmt->execute();
|
|
|
|
// Check if the insertion was successful
|
|
if ($stmt->rowCount() > 0) {
|
|
jsonSuccess(null, "Criminal document data saved successfully");
|
|
} else {
|
|
jsonError("Failed to save criminal document data");
|
|
}
|
|
} catch (PDOException $e) {
|
|
// Log the error and print a generic failure message
|
|
error_log("Database Error: " . $e->getMessage());
|
|
jsonError("An error occurred while saving the data");
|
|
}
|
|
?>
|