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:
Expand|Select|Wrap|Line Numbers
- <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>
Expand|Select|Wrap|Line Numbers
- /* 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 ?