There is a small functionality I want to implement to my existing contact.php script. This is the form: http://i52.tinypic.com/b3rlox.jpg Right now the entire form is being sent to a single email address. I would to be able to send the form to multiple emails depending on which "Clinic of Interest" is chosen as illustrated above. E.g: If I select islington. I want the email to go out to . E.g: Or if I select Brixton I would want the email to go out to . Is this possible? Any assistance would be greatly appreciated. Here's the code I'm using right now: <?php session_start(); if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) { // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. unset($_SESSION['security_code']); $message = " Clinic of Interest: {$_POST['centre']} First Name: {$_POST['firstname']} Sur Name: {$_POST['surname']} Email: {$_POST['email']} Phone: {$_POST['phone']} Additional Comments: {$_POST['comments']} "; $recipient = "email@email.com"; $subject = "Email Subject"; $mailheader = "From: {$_POST['email']}"; mail($recipient, $subject, $message, $mailheader) or die ("Failure"); } else { sleep(2); header("location:failure.html"); } ?> Code (markup): Thanks
Really simple, just check the value of the $_POST['centre'] variable. switch ( $_POST['centre'] ) { case 'islington' : // change it to the value of the option tag in the contact form $recipient = 'islingtonemail@example.com'; break; case 'brixton' : $recipient = 'brixtonemail@example.com'; break; // continue adding more cases and don't forget to add a default case like this... default : $recipient = 'defaultemail@example.com'; break; } PHP: Put the above code before it sends out the mail and remove the line where you set the $recipient variable. I hope it helps.