# Php sending checkbox info to email

**URL:** <https://forum.kirupa.com/t/php-sending-checkbox-info-to-email/177604>\
**Category:** Uncategorized\
**Created:** [February 3, 2006, 9:17am UTC](https://forum.kirupa.com/t/php-sending-checkbox-info-to-email/177604 "2006-02-03T09:17:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wild\_Rose](https://avatars.discourse-cdn.com/v4/letter/w/cc9497/32.png) [@Wild\_Rose](https://forum.kirupa.com/u/Wild_Rose)\
**Post date:** [February 3, 2006, 9:17am UTC](https://forum.kirupa.com/t/php-sending-checkbox-info-to-email/177604/1 "2006-02-03T09:17:56Z")

</div>

I’m very new to php (and programming in general) and have been trying to get  
this form to pass multiple checkbox results to an email address. The rest of  
the form is working perfectly except the checkboxes. I’ve been going round in  
circles for over a week now, so any help would be greatly appreciated.

\<?php  
if ($\_POST) {  
if (get\_magic\_quotes\_gpc()) {  
foreach ($\_POST as $key =\> $value) {  
$temp = stripslashes($value);  
$\_POST[$key] = $temp;  
}  
}  
$to = ‘mail@domain.com’;  
$subject = ‘Feedback from website’;  
// message  
$message = "Event Type: " . $\_POST[‘eventtype’] . "  
";  
$message .= "Event Date: " . $\_POST[‘eventdate’] . "  
";  
$message .= "No of guests: " . $\_POST[‘noofguests’] . "  
";  
$message .= "Desired Location: " . $\_POST[‘desiredlocation’] . "  
";  
foreach($\_POST[‘check’] as $value)  
{  
$check\_msg .= “Checked: $value”. "  
";  
}  
// with this it passes the name array to the email  
// $message .= "Service you require: " . $\_POST[‘check’] . "  
";  
$message .= "First Name: " . $\_POST[‘reqfirstname’] . "  
";  
$message .= "Surname: " . $\_POST[‘reqsurname’] . "  
";  
$message .= "Telephone: " . $\_POST[‘reqphonenumber’] . "  
";  
$message .= "Email: " . $\_POST[‘reqemail’] . "  
";  
$message .= "Address1: " . $\_POST[‘reqaddress1’] . "  
";  
$message .= "Address2: " . $\_POST[‘reqaddress2’] . "  
";  
$message .= "Postcode: " . $\_POST[‘reqpostcode’] . "  
";  
$message .= "Country: " . $\_POST[‘reqcountry’] . "  
";  
$message .= "Contact us by: " . $\_POST[‘contactusby’] . "  
";  
$message .= "Convenient Time: " . $\_POST[‘convenienttime’] . "  
";  
$message .= "How did you find us?: " . $\_POST[‘findus’] . "  
";  
$message .= "Message: " . $\_POST[‘message’] . "  
";

// headers  
$headers = "From: [feedback@domain.com](mailto:feedback@domain.com)  
";  
$headers .= "Reply-To: " . $\_POST[‘email’] . "  
";  
$headers .= "Cc: [email@domain.com](mailto:email@domain.com)  
";  
$headers .= “Content-type: text/plain; charset=UTF-8”;

$sent = mail($to, $subject, $message, $headers, $check\_msg);  
}  
?\>

And the form…

\<form action="\<?php echo $\_SERVER[‘PHP\_SELF’]; ?\>" method=“post” id=“apply” name=“apply” onSubmit=“return checkrequired(this)”\>  
\<dl\>  
\<input name=“check[]” type=“checkbox” value=“service1” title=“service1” \>  
Service1  
\</dd\>  
\<dd\>  
\<input type=“checkbox” name=“check[]” value=“service2” title=“service2” \>  
Service2\</dd\>  
\<dd\>  
\<input name=“check[]” type=“checkbox” title=“service3” value=“service3” \>  
Service3\</dd\>  
\<dd\>  
\</dl\>  
\</form\>
