Jump to content

Send Email based on drop down selection


TwiztedCupid

Recommended Posts

Hi. I want to send an email to a specific person based on the selection made in a drop down list. I'm using Dreamweaver CS4 and Adobe Developer Toolbox for the existing code. Here is some of my code.

 

This first part is where it sends the mail. I need to use the variable in the "setTo" line. I know if I use {Services} it will send it to the values selected in drop down. i.e. [email protected]; [email protected].

 

function Trigger_SendEmail(&$tNG) {
  $emailObj = new tNG_Email($tNG);
  $emailObj->setFrom("[email protected]");
  $emailObj->setTo("VARIABLE HAS TO GO HERE");
  $emailObj->setCC("[email protected]");
  $emailObj->setBCC("");

 

Here is the code for the select:

 

<select name="Services" id="Services">
            <option value=""  <?php if (!(strcmp("", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Select a service...</option>
            <option value="Landscape Maintenance" <?php if (!(strcmp("Landscape Maintenance", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Landscape Maintenance</option>
            <option value="Landscape Design" <?php if (!(strcmp("Landscape Design", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Landscape Design</option>
            <option value="Planting Renovation" <?php if (!(strcmp("Planting Renovation", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Planting Renovation</option>
            <option value="Tree Service" <?php if (!(strcmp("Tree Service", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Tree Service</option>
              <option value="Snowplowing" <?php if (!(strcmp("Snowplowing", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Snowplowing</option>
<option value="Other" <?php if (!(strcmp("Other", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Other</option>
            </select>

 

Is there a way if the user selects "Landscape Maintenance" or "Landscape Design" the email will go to "[email protected]". If they select "Tree Service" it will go to "[email protected]"? Something like:

 

If Services = "Landscape Design" Or "Landscape Maintenance" Then
         $toEmail = "[email protected]"
   Else
   If Services = "Tree Service" Then
        $toEmail = "[email protected]"......and so on.

 

Then place $toEmail into "$emailObj->setTo("$toEmail");"?

 

Link to comment
https://forums.phpfreaks.com/topic/184591-send-email-based-on-drop-down-selection/
Share on other sites

You could do something like this..

 

$emails_array = array(
'Landscape Maintenance'=>'[email protected]',
'Landscape Design'=>'[email protected]',
'Planting Renovation'=>'[email protected]',
'Tree Service'=>'[email protected]',
'Snowplowing'=>'[email protected]',
'Other'=>'[email protected]');

function Trigger_SendEmail(&$tNG) {
  global $emails_array;
  $emailObj = new tNG_Email($tNG);
  $emailObj->setFrom("[email protected]");
  $emailObj->setTo($emails_array[$_POST['Services']]);
  $emailObj->setCC("[email protected]");
  $emailObj->setBCC("");
}

 

Not 100% certain but it should work :P

 

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.