deansp2001 Posted July 4, 2007 Share Posted July 4, 2007 Hi Ive got a script running that allows users to enter information which we receive via email. I want to put a drop down menu on the form where users select "Sales/Support/Marketing" etc. How do I amend the PHP code so that it sends the email to the selected department? Thank you Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 4, 2007 Share Posted July 4, 2007 If you would like to post some code (surround it with CODE tags!) then someone can start to help you. Without code all we can do is guess. Quote Link to comment Share on other sites More sharing options...
deansp2001 Posted July 4, 2007 Author Share Posted July 4, 2007 Sorry - here it is - I did not write this code. <? $from_address = "robinstrutt@gmail.com"; $required_on = "no"; $required_errorpage = "error.html"; $override = "no"; $incoming_mailto = "robinstrutt@gmail.com"; $incoming_subject = "Dacon request Call"; $incoming_thanks = "requestcall2.php"; $ban_ip_on = "no"; $ban_ip_list = "111.222.33.55,11.33.777.99"; $secure_domain_on = "no"; $autorespond_on = "no"; $autorespond_subject = "Car Retail Solutions - Thank you"; $autorespond_from = "robinstrutt@gmail.com"; $autorespond_contents = "Dear Sir/Madam Thank you for reserving your place at the Car Retail Solutions seminar on the 2nd June 2007 If you need any more information please do not hesitate to contact us"; $autorespond_mailto_field = "Email"; if($_SERVER['REQUEST_METHOD'] == "GET") { echo " <html> <head><title>Webligo PHP DynaForm is installed correctly.</title></head> <body> <font style='font-family: verdana, arial; font-size: 9pt;'> <b>DynaForm is installed correctly.</b></font><br> <font style='font-family: verdana, arial; font-size: 8pt;'> DynaForm Easy PHP Form Mailer was created by <a href='http://www.webligo.com'>Webligo Developments</a>. </font> </body></html> "; exit(); } $incoming_fields = array_keys($_POST); $incoming_values = array_values($_POST); if($override == "no") { $incoming_mailto = $_POST['rec_mailto']; $incoming_subject = $_POST['rec_subject']; $incoming_thanks = $_POST['rec_thanks']; } $incoming_mailto_cc = $_POST['opt_mailto_cc']; $incoming_mailto_bcc = $_POST['opt_mailto_bcc']; $form_url = $_POST[HTTP_REFERER]; if($secure_domain_on == "yes") { $form_url_array = parse_url($form_url); $form_domain = $form_url_array[host]; if($form_domain != $_SERVER[HTTP_HOST]) { echo "<h2>DynaForm Error - Invalid Domain</h2> You have accessed DynaForm from an external domain - this is not allowed.<br> You may only submit forms to a DynaForm file that exists on the same domain name.<br> If you believe to be receiving this message in error, please refer to your readme.txt file. <br><br>"; $error = "yes"; } } if($incoming_mailto == "") { echo "<h2>DynaForm Error - Missing Field</h2> Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include the required \"<b>rec_mailto</b>\" field within the form. This field specifies who the email will be sent to. <br><br> This should look like:<br> <input type=\"hidden\" name=\"rec_mailto\" value=\"youremail@yoursite.com\"> <br><br> If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br> "; $error = "yes"; } if($incoming_subject == "") { echo "<h2>DynaForm Error - Missing Field</h2> Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include the required \"<b>rec_subject</b>\" field within the form. This field specifies the subject of the email that will be sent. <br><br> This should look like:<br> <input type=\"hidden\" name=\"rec_subject\" value=\"CRS Seminar 2nd June - Confirmation\"> <br><br> If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br> "; $error = "yes"; } if($incoming_thanks == "") { echo "<h2>DynaForm Error - Missing Field</h2> Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include the required \"<b>rec_thanks</b>\" field within the form. This field specifies what page the user will be taken to after they submit the form. <br><br> This should look like:<br> <input type=\"hidden\" name=\"rec_thanks\" value=\"thanks.html\"> <br><br> If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br> "; $error = "yes"; } if($ban_ip_on == "yes") { if(strstr($ban_ip_list, $_SERVER[REMOTE_ADDR])) { echo "<h2>DynaForm Error - Banned IP</h2> You cannot use this form because your IP address has been banned by the administrator.<br> "; $error = "yes"; } } if($error == "yes") { exit(); } $message = "Please call this customer ASAP \n\n"; for ($i = 0; $i < count($incoming_fields); $i++) { if($incoming_fields[$i] != "rec_mailto") { if($incoming_fields[$i] != "rec_subject") { if($incoming_fields[$i] != "rec_thanks") { if($incoming_fields[$i] != "opt_mailto_cc") { if($incoming_fields[$i] != "opt_mailto_bcc") { if($required_on == "yes") { $sub = substr($incoming_fields[$i], 0, 2); if($sub == "r_") { if($incoming_values[$i] == "" OR !isset($incoming_values[$i]) OR $incoming_values[$i] == " ") { header("Location: $required_errorpage"); exit(); }}} $message .= "$incoming_fields[$i]:\n$incoming_values[$i]\n\n"; }}}}}} $headers = ""; if($from_address != "") { $headers .= "From: $from_address\r\n"; } if($incoming_mailto_cc != "") { $headers .= "Cc: $incoming_mailto_cc\r\n"; } if($incoming_mailto_bcc != "") { $headers .= "Bcc: $incoming_mailto_bcc\r\n"; } mail($incoming_mailto, $incoming_subject, $message, $headers); if($autorespond_on == "yes") { $autorespond_mailto = $_POST[$autorespond_mailto_field]; $autorespond_headers = "From: $autorespond_from"; mail($autorespond_mailto, $autorespond_subject, $autorespond_contents, $autorespond_headers); } header("Location: $incoming_thanks"); ?> Quote Link to comment Share on other sites More sharing options...
deansp2001 Posted July 11, 2007 Author Share Posted July 11, 2007 Can anyone help please? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.