37 lines
997 B
PHP
37 lines
997 B
PHP
<?php
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$id = filterRequest("id");
|
|
|
|
$fields = [];
|
|
$params = [":id" => $id];
|
|
|
|
$encryptedFields = [
|
|
"phone", "sosPhone", "birthdate", "site", "gender",
|
|
"first_name", "last_name", "education", "employmentType", "maritalStatus"
|
|
];
|
|
|
|
foreach ($encryptedFields as $field) {
|
|
if (isset($_POST[$field]) && !empty($_POST[$field])) {
|
|
$value = filterRequest($field);
|
|
$encryptedValue = $encryptionHelper->encryptData($value);
|
|
$fields[] = "`$field` = :$field";
|
|
$params[":$field"] = $encryptedValue;
|
|
}
|
|
}
|
|
|
|
if (!empty($fields)) {
|
|
$setClause = implode(", ", $fields);
|
|
$sql = "UPDATE `passengers` SET $setClause WHERE `id` = :id";
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->execute($params);
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
jsonSuccess(null, "Passenger data updated successfully");
|
|
} else {
|
|
jsonError("Failed to update passenger data");
|
|
}
|
|
} else {
|
|
jsonError("No fields to update");
|
|
}
|
|
?>
|