I have a form that potential clients fill out and then an email is sent to me. On the form I have multiple checkboxes that list different conditions. I can't figure out how to get the checkboxes information to send in the email. The user is able to select as many boxes as they would like but only the last checkbox selected shows up in my email. How do I set up the php file to accept multiple checkbox inputs and send it to me in an email.
Any help would be greatly appreciate!!!
Here is my HTML form code:
<form name="contactform" method="post" action="send_form_email.php">
<table width="546" border="0" cellspacing="15" cellpadding="5">
<tr>
<td colspan="2>Please indicate if you have any of the following:</p>
<p>
<input type="checkbox" name="condition" value="Respiratory condition" />
<input type="checkbox" name="condition" value="Cardiac condition" />
</p></td>
</tr>
<tr>
<td colspan="2"><input name="submit" type="submit" id="submit" value="Submit" /></td>
</tr>
</table>
</form>
Here is my PHP code:
<?php
if(isset($_POST['email'])) {
$email_to = "email@goeshere.com";
$email_subject = "User Information Form";
$name = $_POST['name'];
$telephone = $_POST['telephone'];
$email_from = $_POST['email'];
$employer = $_POST['employer'];
$jobtitle = $_POST['jobtitle'];
$condition = $_POST['condition'];
//ERROR MESSAGES
$error_message = "";
if(strlen($error_message) > 0) {
died($error_message); }
//EMAIL MESSAGE
$email_message = "N95 Respirator User Information Form:\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string); }
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Telephone Number: ".clean_string($telephone)."\n";
$email_message .= "Email Address: ".clean_string($email_from)."\n";
$email_message .= "Employer/School: ".clean_string($employer)."\n";
$email_message .= "Job Title/Program: ".clean_string($jobtitle)."\n";
$email_message .= "Conditions: ".clean_string($condition)."\n";
// EMAIL HEADERS
$headers = 'From: email@goeshere.com."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

