mardi 24 février 2015

Get the values of checkbox


i have a contact form with some checkobox choices :


The html :



<div class="col-xs-6 col-md-6 form-group checkboxEight">
<div class="checkbox c-checkbox"><label><input type="checkbox" value="Seo" name="service[]"/><span class="fa fa-check"></span>seo</label>
</div>
<div class="checkbox c-checkbox "><label><input type="checkbox" value="ppc" name="service[]"/><span class="fa fa-check"></span>ppc</label>

</div>
<div class="checkbox c-checkbox "><label><input type="checkbox" value="social" name="service[]"/><span class="fa fa-check"></span>social media</label>

</div>
<div class="checkbox c-checkbox "><label><input type="checkbox" value="web" name="service[]"/><span class="fa fa-check"></span>web & interface</label></div>
</div>


php :



foreach($_POST['service'] as $selected)
{
//$service[] = $selected;
$service[] = trim($_POST['value']);

}


and $body



$subject = '[Contact Form] From '.$name;
$body = "Name: $name \n\n Email: $email \n\n Tel: $tel \n\n URL: $url \n\n service: $selected \n\n Comments: $comments";
$headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

wp_mail($emailTo, $subject, $body, $headers);
$emailSent = true;


For each checkbox that i select i want to receive via email. Βut now what happens is that only sends the last choice and not those who have chosen.





Aucun commentaire:

Enregistrer un commentaire