jeudi 8 décembre 2016

CheckBox value PHP email

I am quite new to PHP and I have a problem with a form. I have a checkbox and I don't know how to print it on the mail.

Here is the code

`<input type="checkbox" id="bread" name="bread" value="no" unchecked/>     <label for="bread">Bread</label>
 <input type="checkbox" id="pizza" name="pizza" value="no" unchecked/><label for="pizza">Pizza</label>`

and here the PHP that write on the mail the results of the form

`if ($_POST['food'])
$body .= "<p><strong>Wich type of food</strong>: " . $_POST['food'] . "  </p>"; /*this is an imput text that I have in the form*/
if ($bread != 'No') {
$bread = 'Yes';
}
$body .= "<p><strong>Bread</strong>: " . $_POST['bread'] . "</p>";`

I would like that in the mail appear yes if the checkbox is checked and no if is not checked. Thanks in advance for your help.




Aucun commentaire:

Enregistrer un commentaire