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.