34 lines
810 B
PHP
34 lines
810 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../connect.php';
|
|
|
|
// Sanitize and retrieve input parameters
|
|
$driverId = filterRequest("driverId");
|
|
$notes = filterRequest("notes");
|
|
|
|
// SQL: Insert or Update if already exists
|
|
$sql = "INSERT INTO `welcomeDriverCall` (`driverId`, `isCall`, `notes`)
|
|
VALUES (:driverId, '1', :notes)
|
|
ON DUPLICATE KEY UPDATE
|
|
`isCall` = '1',
|
|
`notes` = VALUES(`notes`),
|
|
`createdAt` = NOW()";
|
|
|
|
// Prepare the statement
|
|
$stmt = $con->prepare($sql);
|
|
|
|
// Bind parameters
|
|
$stmt->bindParam(':driverId', $driverId);
|
|
$stmt->bindParam(':notes', $notes);
|
|
|
|
// Execute the statement
|
|
$success = $stmt->execute();
|
|
|
|
if ($success) {
|
|
jsonSuccess(null, "Record inserted/updated successfully");
|
|
} else {
|
|
jsonError("Failed to insert or update record");
|
|
}
|
|
|
|
?>
|