edit user states access

This commit is contained in:
Kar l5
2024-05-03 15:42:01 +05:30
parent b4eba4f4c8
commit c8ab3ad24c

View File

@@ -36,16 +36,28 @@
}
}
$access_value = implode(',', $access_values_array);
$states_list = ["international", "ML", "HR", "MH", "GA", "MN", "PY", "TG", "OR", "RJ", "PB", "UT", "AP", "NL", "LD", "HP", "DL", "UP", "AN", "AR", "JH", "KA", "AS", "KL", "JK", "GJ", "CH", "DH", "SK", "TN", "MZ", "BR", "TR", "MP", "CT", "LA", "WB"];
$states_access_array = [];
foreach ($states_list as $states) {
if (isset($_POST[$states])) {
$states_access_array[] = $_POST[$states];
}
}
$states_access_value = implode(',', $states_access_array);
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = md5($_POST['pass']);
$user_id = $_GET['id'];
$stmt = $conn->prepare("UPDATE users SET name = :name, email = :email, mobile = :mobile, access = :access, pass = :pass WHERE id = :id");
$stmt = $conn->prepare("UPDATE users SET name = :name, email = :email, mobile = :mobile, access = :access, states = :states, pass = :pass WHERE id = :id");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mobile', $phone);
$stmt->bindParam(':access', $access_value);
$stmt->bindParam(':states', $states_access_value);
$stmt->bindParam(':pass', $password);
$stmt->bindParam(':id', $user_id);
$stmt->execute();
@@ -150,7 +162,7 @@
foreach ($states as $state) {
$isChecked = in_array($state["iso2"], $ustate);
echo '<input type="checkbox" id="' . $state["iso2"] . '" name="' . $state["iso2"] . '"'; if($isChecked) echo "checked"; echo ' >';
echo '<input type="checkbox" id="'.$state["iso2"].'" name="'.$state["iso2"].'"'. ' value="' . $state["iso2"] . '" '; if($isChecked) echo "checked"; echo ' />';
echo '<label for="' . $state["iso2"] . '">' . $state["name"] . '</label><br>';
}
}