TwiztedCupid Posted December 10, 2009 Share Posted December 10, 2009 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 More sharing options...
Buddski Posted December 10, 2009 Share Posted December 10, 2009 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 Link to comment https://forums.phpfreaks.com/topic/184591-send-email-based-on-drop-down-selection/#findComment-974470 Share on other sites More sharing options...
TwiztedCupid Posted December 10, 2009 Author Share Posted December 10, 2009 This worked like a charm. Thank you. Link to comment https://forums.phpfreaks.com/topic/184591-send-email-based-on-drop-down-selection/#findComment-974495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.