Jump to content

One form, two dropdowns with selected values going to separate email addresses


witty43

Recommended Posts

Hello, any help would be greatly appreciated. I have two dropdowns with 2 options in each. Customer picks one option from each dropdown and the form gets emailed to addresses from the two selections. The code below gives and error.

 

My form:

<form method="POST" action="quote.php" onsubmit="return checkform(this)">

<input type="hidden" name="agent" value="recipient_1,recipient_2">

<input type="hidden" name="office" value="recipient_3,recipient_4">

<select name="agent" id="agent">

<option value="recipient_1">Agent1 </option>

<option value="recipient_2">Agent2 </option>

</select>

<select name="office" id="office">

<option value="recipient_3">Location1  </option>

<option value="recipient_4">Location2 </option>

</select>

<input type="submit" name="submit" value="Submit">

</form>

 

quote.php is below:

$recipients = array(

 

'recipient_1' => '[email protected]',

'recipient_2' => '[email protected]',

'recipient_3' => '[email protected]',

'recipient_4' => '[email protected]',

);

$exploded_recipients = explode(",",$_REQUEST['agent']);

foreach($exploded_recipients as $value)

{

$my_email = $recipients[$value];

$success = mail($my_email, $Subject, $Body, "From: <$EmailFrom>");

}

 

 

Thanks in advance

what is the error that it gives?

 

i'm guessing its because the drop down selection only POSTs the selected value, not a coma separated list of e-mail addresses which your PHP script is looking for.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.