June 21, 201115 yr Hey everyone, Im making a recommendation form, im just going to copy my current contact form but i need to tweek it a bit. What i need in an input where the person puts in the email address they want to send the recommendation to but it also sends a copy to me aswell, Ive got it set up so that all the emails go to my selected email. But i need to know how to get someone fill in the input and its sent to them aswell. Hope this makes sense? Thanks Megan
June 21, 201115 yr Author Here is my code : I just need to figure out a way for the $emailTo = 'megan.hutchinson@arcsystems.co.uk'; to also send it to $email and $recommend <?php //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactname']) == '') { $hasError = true; } else { $name = trim($_POST['contactname']); } //Check to make sure that the phone field is not empty if(trim($_POST['phone']) == '') { $hasError = true; } else { $phone = trim($_POST['phone']); } //Check to make sure that the phone field is not empty if(trim($_POST['company']) == '') { $hasError = true; } else { $company = trim($_POST['company']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['recommend']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['recommend']))) { $hasError = true; } else { $recommend = trim($_POST['recommend']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'megan.hutchinson@arcsystems.co.uk'; //Put your own email address here $body = "Name: $name \n\nCompany: $company \n\nPhone: $phone \n\nEmail: $email \n\nWho you recommened ARC to: $recommend \n\nComments:\n $comments"; $headers = 'From: ARC UK Systems LTD<'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <head> <title>ARC Systems | IT Support in Essex & London | Contact Us</title> <meta name="description" content="IT Support Services - Since 1992, ARC (UK) Systems Ltd has been successfully providing IT service solutions to customers based nationally across the UK. Supporting over 200 clients and continuingly growing year on year our primary focus is to service the IT requirements of businesses with 5 to 300 users." /> <meta name="keywords" content="managed services,it managed services,managed it services,managed service company,desktop managed services,it support,managed support services,managed service provider,it support services,it services,it support london,managed service companies,it support companies,live person,managed hosting services,it support company,managed services business,managed security,it services management,it managed service,support services it,manage service providers,managed services it,small business it support,managed service,ict managed services,it support uk,network managed services,managed services agreement,computer support london,managed hosting solutions,it support in london,managed network services,it services london,it outsourcing,managed hosting providers,managed services solutions,it support surrey,managed network service,managed services providers,it support midlands,managed services support,it support services london,it service,managed security service provider,it support kent,it support companies london,telecommunications managed services,mobile managed services,network support,hosted it services,hosted services,it support contracts,managed services uk,computer support,it support contract,outsourced it support,managed security services,it solutions,network security,london it support,managed services hosting,hosting managed services,managed it solutions,software as a service,it managed service providers,managed services software,small business computer support,it support systems,it support milton keynes,managed services definition,business computer support,it support network,outsourced it services,it business support,it support solutions,computer network support,it support services uk,server management,it support help desk,it consulting,data managed services,managed services companies,managed services provider,it support business,it outsourcing services,it outsourcing companies,it management,managed service providers" /> <link href="css/style.css" media="screen" rel="stylesheet" type="text/css" /> <!--[if gte IE 8]> <link rel="stylesheet" type="text/css" href="css/ie8.css" /> <![endif]--> <!--[if lte IE 7]> <link rel="stylesheet" type="text/css" href="css/ie7.css" /> <![endif]--> <!--[if lt IE 7.]> <script defer type="text/javascript" src="pngfix.js"></script> <![endif]--> </head> <body id="bodyWrapper"> <div id="contact-wrapper"> <div id="emailRibbon"><p>Email Us</p></div> <?php if(isset($hasError)) { //If errors are found ?> <p class="error">Please check if you've filled all the fields with valid information. Thank you.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <p><strong>Email Successfully Sent!</strong></p> <p>Thank you <strong><?php echo $name;?></strong> for using my contact form! Your email was successfully sent and we will be in touch with you soon.</p> <?php } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform"> <div> <label for="name"><strong>Name:</strong></label> <input type="text" size="50" name="contactname" id="contactname" value="" class="required" /> </div> <div> <label for="phone"><strong>Company</strong></label> <input type="text" size="50" name="company" id="company" value="" class="required" /> </div> <div> <label for="phone"><strong>Phone:</strong></label> <input type="text" size="50" name="phone" id="phone" value="" class="required" /> </div> <div> <label for="email"><strong>Your Email:</strong></label> <input type="text" size="50" name="email" id="email" value="" class="required email" /> </div> <div> <label for="email"><strong>Who do you want to recommend us to?</strong></label> <input type="text" size="50" name="recommend" id="recommend" value="" class="required email" /> </div> <div> <label for="message"><strong>Message:</strong></label> <textarea rows="5" cols="50" name="message" id="message" class="required"></textarea> </div> <input class="button"type="submit" value="Send" name="submit" /> <input class="button" type="reset" name="button2" id="button2" value="Reset" /> </form> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" src="http://www.arcsystems.co.uk/js/arcsystems.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#contactform").validate(); }); </script> <script type="text/javascript"> $(document).ready(function() { try { $("#subject").msDropDown({mainCSS:'dd2'}); //alert($.msDropDown.version); //$.msDropDown.create("body select"); $("#ver").html($.msDropDown.version); } catch(e) { alert("Error: "+e.message); } }) </script> <script type="text/javascript"> $(document).ready(function() { try { $("#howdidyoufindus").msDropDown({mainCSS:'dd2'}); //alert($.msDropDown.version); //$.msDropDown.create("body select"); $("#ver").html($.msDropDown.version); } catch(e) { alert("Error: "+e.message); } }) </script> </body> </html>
Create an account or sign in to comment