Hi, my site has a contact form that allows customers to send a message. The contact form has a drop down menu which allows the customer to choose from 3 products that they want to enquire about. I have 3 different email addresses for each product as 3 different administrators are responsible for each product. At the moment the contact form is emailed to all 3 administrators. How can i change my code below so that if a certain product is selected from the contact form, only the administrator responsible for that product is emailed CONTACT FORM <form name="contact" id="form" action="contact.processor.php" onSubmit="return validate_form(this);" enctype="multipart/form-data" method="post"> <div class="form_heading">Name:</div> <div><input type="text" class="form_input" name="name" size="30" maxlength="35" tabindex="1" /></div> <div class="form_heading">Phone Number:</div> <div><input type="text" class="form_input" name="phone" size="30" maxlength="20" tabindex="2" /></div> <div class="form_heading">Email:</div> <div><input type="text" class="form_input" name="email" size="30" maxlength="49" tabindex="3" /></div> <div class="form_heading">Product:</div> <div> <select name="product" tabindex="4"> <option value="All" selected>--- All Products ---</option> <option value="Product A">Product A</option> <option value="Product B">Product B</option> <option value="Product C">Product C</option> </select> </div> <div><input name="submit" tabindex="5" type="submit" id="submit" value="Send" /> <input type="reset" tabindex="7" name="Reset" value="Reset" /></div> </form> HTML: <?php $todayis = date("l, F j, Y, g:i a") ; $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $product = $_POST['product']; $body = " $todayis [EST] \n Name: $name \n Phone: $phone \n Email: $email \n Product Enquiry: $product \n "; $to = "product-a@gmail.com, product-b@gmail.com, product-c@gmail.com"; $subject = "Contact Us"; $from = "From: $email\r\n"; mail($to, $subject, $body, $from); ?> PHP: Thanks in advance...
Something like the following should work, ideally you want to add some server side validation as well as client side, if the user has JavaScript disabled they can send a blank mail through. Code below is untested. <?php $todayis = date("l, F j, Y, g:i a") ; $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $product = $_POST['product']; $body = " $todayis [EST] \n Name: $name \n Phone: $phone \n Email: $email \n Product Enquiry: $product \n "; switch($product) { case "All": $to = "product-a@gmail.com, product-b@gmail.com, product-c@gmail.com"; break; case "Product A": $to = "product-a@gmail.com"; break; case "Product B": $to = "product-b@gmail.com"; break; case "Product C": $to = "product-c@gmail.com"; break; } $subject = "Contact Us"; $from = "From: $email\r\n"; mail($to, $subject, $body, $from); PHP: