Update: 2026-06-11 18:22:57

This commit is contained in:
Hamza-Ayed
2026-06-11 18:22:59 +03:00
parent c5170a88d2
commit 727068b668
629 changed files with 46050 additions and 46109 deletions

View File

@@ -0,0 +1,43 @@
<?php
include "../connect.php";
// Retrieve and sanitize input parameters
$driverId = filterRequest("driverId");
$carPlate = filterRequest("carPlate");
// Start a transaction
$con->beginTransaction();
try {
// Update CarRegistration table
$sqlUpdate = "UPDATE `CarRegistration` SET `car_plate` = :carPlate WHERE `driverID` = :driverId";
$stmtUpdate = $con->prepare($sqlUpdate);
$stmtUpdate->bindParam(':carPlate', $carPlate);
$stmtUpdate->bindParam(':driverId', $driverId);
$stmtUpdate->execute();
// Check if the update was successful
if ($stmtUpdate->rowCount() > 0) {
// Insert into carPlateEdit table
$sqlInsert = "INSERT INTO `carPlateEdit` (`driverId`, `carPlate`, `isEdit`) VALUES (:driverId, :carPlate, 1)";
$stmtInsert = $con->prepare($sqlInsert);
$stmtInsert->bindParam(':driverId', $driverId);
$stmtInsert->bindParam(':carPlate', $carPlate);
$stmtInsert->execute();
// Commit the transaction
$con->commit();
// Print a success message
printSuccess("Car plate updated and edit record inserted successfully");
} else {
// Rollback the transaction if update failed
$con->rollBack();
printFailure("Failed to update car plate. No matching record found.");
}
} catch (PDOException $e) {
// Rollback the transaction if any error occurred
$con->rollBack();
printFailure("An error occurred: " . $e->getMessage());
}
?>