Thursday, 3 October 2013

php mailer email something other than option value

php mailer email something other than option value

I have built a form on my site that acts as a quote calculator, a user
selects options, each option has a value and those values are added up and
displayed as the final quote. I now need to be able to email that form
which I'm doing using a php mailer.
The issue I'm having is that as far as I can tell, the mailer just sends
the value of the selected options, and not the name. Below is a snippet of
code from my form:
<form action="quote_mailer.php" method="POST">
// Some more select options... //
<select class="select" id="singerName" name="singerName">
<option value="0" name="first"></option>
<option value="195" name="jack">Jack</option>
<option value="195" name="james">James</option>
<option value="195" name="toni">Toni</option>
<option value="195" name="yvonne">Yvonne</option>
</select>
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
And for my php:
<?php
$name = $_POST['quote_name'];
$email = $_POST['quote_email'];
$number = $_POST['quote_number'];
$singerName = $_POST['singerName'];
$formcontent="From: $name \n Number: $number \n Email: $email \n Event
Type: $eventType \n Singer Name: $singerName \n Instruments:
$instruments";
$recipient = "sam.skirrow@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $quote_email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
As you can see from the above code, in my email this returns "Singer Name:
195" as that is the option value, but I need it to return the option NAME
- is this possible?

No comments:

Post a Comment