state access
This commit is contained in:
@@ -117,10 +117,33 @@
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<p style="font-size: 16px; font-weight: bold; margin-top: 10px;">Access by state:</p>
|
||||
<div class="flex" id="stateList"><!-- State checkboxes will be dynamically added here --></div>
|
||||
<hr> <br>
|
||||
|
||||
<div class="flex flex-row">
|
||||
<input type="checkbox" name="international" id="international" value="international" />
|
||||
<label for="international" style="text-transform: uppercase;">international</label>
|
||||
</div>
|
||||
<br> <hr> <br>
|
||||
|
||||
<div style="height:200px; overflow:scroll;white-space: nowrap; overflow-x: visible;">
|
||||
|
||||
<?php
|
||||
$states =
|
||||
array( array("id"=>4006, "name"=>"Meghalaya", "iso2"=>"ML"), array("id"=>4007, "name"=>"Haryana", "iso2"=>"HR"), array("id"=>4008, "name"=>"Maharashtra", "iso2"=>"MH"), array("id"=>4009, "name"=>"Goa", "iso2"=>"GA"), array("id"=>4010, "name"=>"Manipur", "iso2"=>"MN"), array("id"=>4011, "name"=>"Puducherry", "iso2"=>"PY"), array("id"=>4012, "name"=>"Telangana", "iso2"=>"TG"), array("id"=>4013, "name"=>"Odisha", "iso2"=>"OR"), array("id"=>4014, "name"=>"Rajasthan", "iso2"=>"RJ"), array("id"=>4015, "name"=>"Punjab", "iso2"=>"PB"), array("id"=>4016, "name"=>"Uttarakhand", "iso2"=>"UT"), array("id"=>4017, "name"=>"Andhra Pradesh", "iso2"=>"AP"), array("id"=>4018, "name"=>"Nagaland", "iso2"=>"NL"), array("id"=>4019, "name"=>"Lakshadweep", "iso2"=>"LD"), array("id"=>4020, "name"=>"Himachal Pradesh", "iso2"=>"HP"), array("id"=>4021, "name"=>"Delhi", "iso2"=>"DL"), array("id"=>4022, "name"=>"Uttar Pradesh", "iso2"=>"UP"), array("id"=>4023, "name"=>"Andaman and Nicobar Islands", "iso2"=>"AN"), array("id"=>4024, "name"=>"Arunachal Pradesh", "iso2"=>"AR"), array("id"=>4025, "name"=>"Jharkhand", "iso2"=>"JH"), array("id"=>4026, "name"=>"Karnataka", "iso2"=>"KA"), array("id"=>4027, "name"=>"Assam", "iso2"=>"AS"), array("id"=>4028, "name"=>"Kerala", "iso2"=>"KL"), array("id"=>4029, "name"=>"Jammu and Kashmir", "iso2"=>"JK"), array("id"=>4030, "name"=>"Gujarat", "iso2"=>"GJ"), array("id"=>4031, "name"=>"Chandigarh", "iso2"=>"CH"), array("id"=>4033, "name"=>"Dadra and Nagar Haveli and Daman and Diu", "iso2"=>"DH"), array("id"=>4034, "name"=>"Sikkim", "iso2"=>"SK"), array("id"=>4035, "name"=>"Tamil Nadu", "iso2"=>"TN"), array("id"=>4036, "name"=>"Mizoram", "iso2"=>"MZ"), array("id"=>4037, "name"=>"Bihar", "iso2"=>"BR"), array("id"=>4038, "name"=>"Tripura", "iso2"=>"TR"), array("id"=>4039, "name"=>"Madhya Pradesh", "iso2"=>"MP"), array("id"=>4040, "name"=>"Chhattisgarh", "iso2"=>"CT"), array("id"=>4852, "name"=>"Ladakh", "iso2"=>"LA"), array("id"=>4853, "name"=>"West Bengal", "iso2"=>"WB") );
|
||||
$user_states = $conn->prepare("SELECT `states` FROM `users` WHERE `id` = '".$_GET["id"]."'");
|
||||
$user_states->execute();
|
||||
$ustate = $user_states->fetchAll(PDO::FETCH_COLUMN);
|
||||
$ustate=explode(",", $ustate[0]);
|
||||
|
||||
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 '<label for="' . $state["iso2"] . '">' . $state["name"] . '</label><br>';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<label for="pass">Password:</label>
|
||||
<input type="text" name="pass" id="pass" />
|
||||
@@ -142,32 +165,7 @@
|
||||
}
|
||||
|
||||
?>
|
||||
<script>
|
||||
// JavaScript code to fetch data and populate checkboxes
|
||||
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=IN`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const stateList = document.getElementById('stateList');
|
||||
data.forEach(state => {
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.type = 'checkbox';
|
||||
checkbox.value = state.iso2;
|
||||
checkbox.name = 'selectedStates[]'; // Adjust name as per your form's needs
|
||||
|
||||
const label = document.createElement('label');
|
||||
label.appendChild(checkbox);
|
||||
label.appendChild(document.createTextNode('\u00A0' + state.name)); // Adding a non-breaking space before the state name
|
||||
<?php
|
||||
foreach($seletedState as $pre_state){
|
||||
?>
|
||||
if("<?php echo $pre_state; ?>".includes(state.iso2)) {
|
||||
checkbox.checked = true;
|
||||
}
|
||||
<?php } ?>
|
||||
stateList.appendChild(label);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
/* For small screens */
|
||||
@media screen and (max-width: 767px) {
|
||||
|
||||
Reference in New Issue
Block a user