Hello everyone.
I am a real newbie to php, and this is my first attempt at writing anything.
I have created a Contact Form in html with a drop down selection box, which sends the completed form content to a different recipient depending on which option is selected in the drop down box.
All is working fine (much to my amazement and with a little help from others) EXCEPT, I am stuck with one part. When the form content is sent to the recipient, it shows the option value rather than the option text, and I cannot work my head around how to get it to show the text.
The relevant part of the Contact Form HTML code is:
and the PHP code is:
So, basically, in the php above, within the 'body' i.e. the information being emailed, I have "Nature: $Nature", which returns the option value. I am trying to get it to return the option text itself to clarify the nature of the enquiry ( there are a couple of recipients who will receive emails for more than 1 type of enquiry and I need to show them which one it covers)Example: Assuming a user selects Hall Hire, it will currently send "recipient 2". I want it to send "Hall Hire" i.e the option text itself rather than the option value.
Is there a simple way of doing this ? Can anyone guide me please ?
I am a real newbie to php, and this is my first attempt at writing anything.
I have created a Contact Form in html with a drop down selection box, which sends the completed form content to a different recipient depending on which option is selected in the drop down box.
All is working fine (much to my amazement and with a little help from others) EXCEPT, I am stuck with one part. When the form content is sent to the recipient, it shows the option value rather than the option text, and I cannot work my head around how to get it to show the text.
The relevant part of the Contact Form HTML code is:
Code:
<select name="Nature" size="1" id="Nature"> <option>Please Select</option> <option value="recipient_1">General Enquiries</option> <option value="recipient_2">Hall Hire</option> <option value="recipient_3">Marquee Hire</option> <option value="recipient_4">Parish Church</option> <option value="recipient_5">Parish Council</option> <option value="recipient_6">Recreation Area</option> <option value="recipient_7">Other</option> </select>
Code:
/* Email Variables */ $emailSubject = 'website_enquiry'; $recipients = array( 'recipient_1' => 'kim@example.com', 'recipient_2' => 'kim2@example.com', 'recipient_3' => 'kms3@example.com', 'recipient_4' => 'kim4@example.com', 'recipient_5' => 'kim5@example.com', 'recipient_6' => 'kim6@example.com', 'recipient_7' => 'kim7@example.com' ); $my_email = $recipients[$_POST['Nature']]; /* Data Variables */ $Name = $_POST['Name']; $Telephone = $_POST['Telephone']; $Email = $_POST['Email']; $Nature = $_POST['Nature']; $Questions = $_POST['Questions']; $body = <<<EOD <br><hr><br> Name: $Name <br> Telephone: $Telephone <br> Email: $Email <br> Nature: $Nature <br> Questions: $Questions <br> EOD; $headers = "From: $Email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($my_email, $emailSubject, $body, $headers);
Is there a simple way of doing this ? Can anyone guide me please ?
Comment