Hello I am creating a HTML + PHP email form. My form and function is working perfectly aside from my checkboxes. I have two checkboxes.
<input type="checkbox" id="boxfan" name="boxfan[]"/>
<label for="boxfan">A fan?</label>
<input type="checkbox" id="boxgbps" name="boxfan[]"/>
<label for="boxalbum">Bought an album?</label>
I want the value to be send as Yes or No, send Yes if the checked and No if unchecked.
For example:
A fan? Yes
Bought an album? No
Any, suggestion is appreciated. Thanks.
My actual form is here It's in Danish that's why I just used a simple example.
$yn = (isset($_POST['boxfan'][$i])) ? 'Yes' : 'No'. Since checkboxes aren't submitted unless they ARE checked, the mere presence of the checkbox's name in _POST means it was checked.+1) is a good method, using a ternary operator.