I’m trying to make a simple contact form, but I have difficulty to understand how checkbox works. This is the part I have a problem:
HTML:
<input name="selection" type="checkbox">
PHP:
$selection = $_POST['selection'];
$mail->Body = "
Answer is ".$_POST["selection"]."
"
Once the checkbox is clicked and the form is submitted, the function above prints "Answer is on" in the e-mail.
How can I print "Answer is Positive" once checkbox is clicked, and "Answer is Negative" when checkbox is not clicked in a simple way?
2
Answers
Alright, I didn't know that defining a custom positive value for a checkbox is so simple:
HTML
As for posting the negative value, I realized that it's not that necessary for my project. For those who wonder how, all alternatives are explained here:
POST unchecked HTML checkboxes
This is what I’ve tried, I don’t know if it solves your question…