View Full Version : PHP Contact form with image verification - Select email recipient from dropdown list
LIQUID FIRE
12-18-2008, 11:34 PM
I am using the PHP Contact form with image verification. http://www.thewebhelp.com/php/php_contact_form_with_image_validation/
I would like users to be able to pick the email recipient from a dropdown list. What coding is required in index.php and mailer.php to make this possible?
LIQUID FIRE
12-21-2008, 04:43 PM
For those that might ask the same question in the future, I found the answer.
Add this in the index.php file where you wan't the dropdown menu.
Send To:<br />
<select name="sendto">
<option value="recipient_1">Recipient #1</option>
<option value="recipient_2">Recipient #2</option>
<option value="recipient_3">Recipient #3</option>
</select>
Add this to the mailer.php
$recipients = array(
'recipient_1' => 'recipient1@mydomain.com',
'recipient_2' => 'recipient2@mydomain.com',
'recipient_3' => 'recipient3@mydomain.com'
);
$my_email = $recipients[$_REQUEST['sendto']];
Make sure that it is above this line.
mail('recipient@mydomain.com', 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
Change 'recipient@mydomain.com' to $my_email.
Make sure that it is not in quotes.
I hope this helps someone.
glenng
01-05-2009, 06:36 AM
Im looking for the user to select a product from the Drop Down Menu.
Can I use the above code for index.php?
What code is needed for mailer.php?
vBulletin® v3.6.8, Copyright ©2000-2010, Jelsoft Enterprises Ltd.