Code writing for an upload failure in the CheckBox multiple selection box in PHP.
When using Java and other languages, form upload can be uploaded only when the name of the checkbox is the same.
<Input type = "checkbox" name = "checkbox" value = "1"> Option <input type = "checkbox" name = "checkbox" value = "2"> Option <input type = "checkbox" name = "checkbox" value = "3"> Option <input type = 'button 'value =' OK 'onclick = "fun () "/>
However, PHP only needs to write the name as an array in this case to submit the form normally.
<Input type = "checkbox" name = "checkbox []" value = "1"> Option 1 <input type = "checkbox" name = "checkbox []" value = "2 "> Option 2 <input type =" checkbox "name =" checkbox [] "value =" 3 "> Option 3 <input type =" checkbox "name =" checkbox []" value = "4"> Option 4 <input type = "checkbox" name = "checkbox []" value = "5"> Option 5 <input type = "checkbox" name =" checkbox [] "value =" 6 "> Option 6 <input type = 'button 'value = ''onclick =" fun () "/>
The following is a question about how PHP handles Checkbox form submission.
Add [] to the name of the PHP form submission page check box so that the correct result can be obtained on the receiving page. After the form is submitted, an array is obtained, and the vaule value of the form is obtained by accessing the array element. The checkbox1 value. The default value is </br>.
Form code:
<Form action = "" method = "post" name = "asp"> check box 1: <input type = "checkbox" name = "checkbox1 []" value = "1"/> check box 2: <input type = "checkbox" name = "checkbox1 []" value = "2"/> check box 3: <input type = "checkbox" name = "checkbox1 []" value = "3"/> <input type = "submit" name = "Download" vaue = "Download"/> </form>
PHP Processing Form code:
<?php if(isset($_POST["Download"])) { foreach($_REQUEST['checkbox1'] as $checkbox1) { echo $checkbox1; } } ?>
The above section describes how to write the code that failed to upload the CheckBox multi-choice box in PHP. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!