prepare("UPDATE customers SET name=?, phone=?, address=?, district=? WHERE id=?");
$stmt->bind_param("ssssi", $name, $phone, $address, $district, $_SESSION['customer_id']);
if ($stmt->execute()) { $_SESSION['customer_name'] = $name; $msg = '
Profile updated successfully!
'; $customer = getCustomer($_SESSION['customer_id']); } else { $msg = 'Update failed.
'; }
if (!empty($_POST['current_password']) && !empty($_POST['new_password'])) {
if (password_verify($_POST['current_password'], $customer['password'])) {
$np = password_hash($_POST['new_password'], PASSWORD_DEFAULT);
$stmt = $conn->prepare("UPDATE customers SET password=? WHERE id=?");
$stmt->bind_param("si", $np, $_SESSION['customer_id']); $stmt->execute();
$msg .= 'Password changed!
';
} else { $msg .= 'Current password is wrong.
'; }
}
}
define('PAGE_TITLE', 'Profile');
include 'dashboard-header.php'; ?>
My Profile
= $msg ?>