Files
intaleq_v3_pure_php/serviceapp/addWelcomeDriverNote.php
2026-04-28 13:04:27 +03:00

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");
}
?>