note 69741 deleted from reserved.variables by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 11:34:00 +0000 |
| Subject: | note 69741 deleted from reserved.variables by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212913@lists.php.net to get a copy of this message | ||
Note Submitter: Alexander Hars
----
If you want to use a form with multiple checkboxes (e.g. one per row) and assign the same name to
each checkbox then the name needs to end with []. This tells PHP to put all checked values into an
array variable.
For example:
<input type="checkbox" name="id[]" value="value_1">
<input type="checkbox" name="id[]" value="value_2">
..
<input type="checkbox" name="id[]" value="value_x">
You can now retrieve all values by using:
$values = $_POST['id'];
If the name does not end with [], then only a single value will be available via the $_POST variable
even if the user checks several checkboxes.