I would like to send inputs and checkboxes values via POST method to php page for updating myql database table, the problem is that I cannot receive uncheked chechboxes, please look at the code below :
index.html :
<form id='form1' method='post' action='update.php'>
<input type='hidden' name='id[]' value='1'>
<input type='text' name='firstName[]' value='John'>
<input type='checkbox' name="married[]" value='1' checked>
<br/>
<input type='hidden' name='id[]' value='2'>
<input type='text' name='firstName' value='Linda'>
<input type='checkbox' name="draft" value='1'>
<br/>
<input type='hidden' name='id[]' value='3'>
<input type='text' name='firstName' value='Mercedes'>
<input type='checkbox' name="draft" value='1' checked>
<br/>
<input type='button' name='submit' value='update'>
</form>
update.php
<?php
print_r($_POST);
?>
The content of the $_POST is :
Array
(
[id] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
[firstName] => Array
(
[0] => 'John'
[1] => 'Linda'
[2] => 'Mercedes'
)
[married] => Array
(
[0] => 1
[1] => 1
)
Like you see the 'married' fields is only received when checkboxes are checked, mean that Linda will be ignored, and mercedes will get the value 1 (married) of Mercedes.
How Can I resolve this?
Aucun commentaire:
Enregistrer un commentaire