Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.