I am trying to create a quotation form. This will be email to myself and the person who has filled in the form. I want to echo the selected value (I currently have this working) & assign a integer value to the selection. I then want to add the integers up to give a total. In my example below I have just included one selection but I will have quite a few of them in the form. Any help would be great!
<label>What time would you like to start?
<select required name="drop_off_time" id="drop_off_time-select" value="<?php if(isset($_POST['drop_off_time'])) echo $_POST['drop_off_time'];?>">
<option value="0"></option>
<option value="8:00am">8:00am</option>
<option value="8:30am">8:30am</option>
<option value="9:00am">9:00am</option>
</select>
</label>
if(isset($_REQUEST['drop_off_time']) && $_REQUEST['drop_off_time'] == '0') {
echo 'Please select a time.';
}
$drop_off_time = $_POST['drop_off_time'];
$emailTo = 'me@gmail.com';
$subject = 'Fees Form Submission from '.$name;
$sendCopy = trim($_POST['sendCopy']);
$body = "Name: $name
Email: $email
Comments: $comments
Drop Off Time: $drop_off_time
Total: £$total";
$headers = 'From: My Site <'.$emailTo.'>' . "
" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
This all works fine. My problem is that I want to assign an integer to the selection. I've done this using a switch but it keeps printing out the selected value not the new value I have assigned. The code for this is below.
$drop_off_time_price = 0;
switch ($drop_off_time_price) {
case 0;
echo 0;
break;
case "8:00am":
echo 100;
break;
case "8:30am":
echo 10000;
break;
case "9:00am":
echo 100000;
break;
}
//Getting the total
$total = $drop_off_time_price;
This is what the email looks like
Name: Frank
Email: me@mail.com
Comments: I get the selected value but no the total....
Drop Off Time: 8:00am
Total: £0