Hi guys. Have a form all working well apart from the following:
Am trying to email a value when a user selects 3 options from a selection box
I am using the following code in my form
<div class="span-6 last">
<li>
<label for="vanType">Do you require:</label>
<select id="van_type" name="van_type" value="<?php if(isset($_POST['van_type'])) echo $_POST['van_type'];?>" class="requiredField packing" />
<option value=" " >- Please select -</option>
<option value="One Man">One Man and Van</option>
<option value="Two Men and Van">Two Men and Van</option>
<option value="Two Men and Two Vans">Two Men and Two Vans</option>
</select>
<?php if($van_typeError != ' ') { ?>
<span class="error"><?=$van_typeError;?></span>
<?php } ?>
</li>
</div>
Then I use the following to handle the form details
//Check to make sure sure that van type is submitted
if(trim($_POST['van_type']) === '') {
$van_typeError = 'Please select man van type';
$hasError = true;
} else {
$van_typeError = trim($_POST['van_type']);
}
Then it gets emailed if the user selects one of the options like so
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'myemail';
$subject = 'Home Removal Quote from '.$name;
$sendCopy = trim($_POST['sendCopy']);
$body = "Name: $name \
\
Phone: $phone \
\
Mobile: $mobile \
\
Email: $email \
\
Date of Removal: $datepicker \
\
Packaging Service: $packing \
\
Stop on Route: $stop_on_route \
\
Van Type: $van_type \
\
Comments: $comments";
$headers = 'From: Home Removal Quote <'.$emailTo.'>' . "\\r\
" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
if($sendCopy == true) {
$subject = 'You emailed Your Name';
$headers = 'From: Go Man and Van <info@gomanandvan.co.uk>';
mail($email, $subject, $body, $headers);
}
$emailSent = true;
}
}
} ?>
Have all working correctly with my other form fields but cannot get a value emailed. Any ideas why guys. Thanks