Example of PHP processing Checkbox multi-choice Box form elements-PHP source code

Source: Internet
Author: User
Tags php form php form processing
The Checkbox value acquisition method is different from the normal input method. Let's take a look at an example of PHP processing Checkbox multi-choice Box form elements, I hope you will know how to use php to accept the checkbox value. The Checkbox value acquisition method is different from the normal input method. Let's take a look at an example of PHP processing Checkbox multi-choice Box form elements, I hope you will know how to use php to accept the checkbox value.

Script ec (2); script

Recently, when submitting a Form, the data submitted by the check box Checkbox does not know how to handle the data. Checkbox allows multiple options. It is impossible for us to customize the Name attribute for each option and then obtain it in the background one by one, this is also inconvenient for expansion.

Later, I checked some information and found that the key point was the Name attribute of the Checkbox. You need to provide a uniform array Name for the checkbox, for example, mycheckbox [], which is a method for defining arrays in PHP. Then obtain the data in the background, for example, $ _ POST ['mycheckbox'] In the POST form. At this time, the data is already an array. The following is a simple example.

Form code

Html
Css

PHP form processing

Var_dump ($ _ POST );
If (isset ($ _ POST ["holobby"]) {
Foreach ($ _ POST ["holobby"] as $ holobby ){
Echo "language: {$ holobby}
";
}
}

In fact, you can use this method to obtain values in batches in any text box with the same data, not limited to CheckBox.

Related Article

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.