Code writing for an upload failure in the CheckBox multiple selection box in PHP.

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.