How to read if a checkbox is checked in PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Is there a way to play audio on a mobile browser w
If your HTML page looks like this:
After submitting the form you can check it with:
or
When using checkboxes as an array:
You should use
in_array()
:Remember to check the array is set first, such as:
Short circuit evaluation will take care so that you don't access
your_checkbox_name
when it was not submitted.in BS3 you can put
Please Note the usage of
isset($datosOrdenCompra[0]['exenta'])
You can check the corresponding value as being set and non-empty in either the $_POST or $_GET array depending on your form's action.
i.e.: With a POST form using a
name
of "test" (i.e.:<input type="checkbox" name="test">
, you'd use:You can do it with the short if:
or with the new PHP7
Null coalescing operator