Initial commit with updated Auth and media ignored
This commit is contained in:
37
ride/profile/update.php
Normal file
37
ride/profile/update.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user