I am doing a PHP assignment where I am getting input that uses some checkboxes and stores the information in a file.
Let's say I have a checkbox
Active: <input type="checkbox" name="preference" value="Pepperoni" checked="checked>
When I say something like:
$Preference1 = $_POST['preference'];
What is stored in $Preference1
? Does it store information that tells whether the box was checked or not, or does it contain "Pepperoni"
? Is there a way to check to see if a box is checked? Like,
Pesudocode
if Preference1 is checked
add Pepperoni to the file;
if Preference2 is checked
add Sausage to the file;
I did work with radio buttons but those are a bit different since only one of those can be checked at a time, but for checkboxes, multiples boxes and be selected. Is there a way to see if a button is checked and if so, how would I do that? Thanks.
Aucun commentaire:
Enregistrer un commentaire