imjeffw Posted July 22, 2011 Share Posted July 22, 2011 Hello, I'm trying to modify my mailer script so I can see the one of the form input fields in the subject line of the admin email. I have no experience coding but I've been successful making minor edits to other php code. Not so successful this time. here is the line collecting the information I want to use in the subject line if($_POST['companyName'] != "") $message .= "Company: ".$_POST['companyName']."<br>"; this is the line driving the subject line. $subject_admin_email = "Web Form - Free License Registration"; I would like the subject line to have the company's name after the free registration. Thanks in advance for any help you can provide Quote Link to comment https://forums.phpfreaks.com/topic/242631-how-to-show-input-value-in-email-subject-line/ Share on other sites More sharing options...
AyKay47 Posted July 22, 2011 Share Posted July 22, 2011 would be much easier to piece this together if I could see the entire code please Quote Link to comment https://forums.phpfreaks.com/topic/242631-how-to-show-input-value-in-email-subject-line/#findComment-1246131 Share on other sites More sharing options...
imjeffw Posted July 22, 2011 Author Share Posted July 22, 2011 Here's the rest of it! minus the download down load paths (don't want it published on a forum) <?php include('../captcha/captchac_lib.php'); $Turing_code = $_REQUEST["Turing"]; if (CheckCaptcha($Turing_code) !=1 ) { echo "<b><font color=red>Sorry, the Captcha Code you entered did not match. Please go back and try again</font></b><br>"; exit; } $website = "http://OnHoldMusicSource.com"; $admin_email = "info@basonhold.com, emailcapture@basonhold.com"; $emailFrom = "licensing@basonhold.com"; $subject_admin_email = "Web Form - Free License Registration"; $subject_user_email = "Your Free Music On Hold Selection"; if(isset($_POST['email']) && $_POST['email'] != "" && isset($_POST['music']) && $_POST['music'] != "" && isset($_POST['voice']) && $_POST['voice'] != "") { //---This section was intentionally removed ---// if($Email[$_POST['music']][$_POST['voice']]) { //---------------------- Send User Email ------------------------------// $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=\"UTF-8\"\n" . "Content-transfer-encoding: 8bit\n"; $message = file_get_contents($Email[$_POST['music']][$_POST['voice']]); $html_text = ""; $html_text=" <HTML> $message </HTML> "; mail($_POST['email'], $subject_user_email, $html_text, $emailHeader); //---------------------- Send Admin Email ------------------------------// $message = ""; $message .= "Dear Admin,<br><BR>"; $message .= "A new Free Message On Hold Request on <b>".$website."</b> at ".date("Y-m-d H:i:s").".<br />"; if($_POST['music'] != "") $message .= "Music: ".$_POST['music']."<br>"; if($_POST['voice'] != "") $message .= "Voice: ".$_POST['voice']."<br>"; if($_POST['firstName'] != "") $message .= "First Name: ".$_POST['firstName']."<br>"; if($_POST['lastName'] != "") $message .= "Last Name: ".$_POST['lastName']."<br>"; if($_POST['email'] != "") $message .= "Email: ".$_POST['email']."<br>"; if($_POST['phone'] != "") $message .= "Phone: ".$_POST['phone']."<br>"; if($_POST['phoneExt'] != "") $message .= "Ext: ".$_POST['phoneExt']."<br>"; if($_POST['companyName'] != "") $message .= "Company: ".$_POST['companyName']."<br>"; if($_POST['address1'] != "") $message .= "Address 1: ".$_POST['address1']."<br>"; if($_POST['address2'] != "") $message .= "Address2: ".$_POST['address2']."<br>"; if($_POST['city'] != "") $message .= "City: ".$_POST['city']."<br>"; if($_POST['state'] != "") $message .= "State: ".$_POST['state']."<br>"; if($_POST['zip'] != "") $message .= "Zip: ".$_POST['zip']."<br>"; if($_POST['country'] != "") $message .= "Country: ".$_POST['country']."<br>"; if($_POST['multiLocations'] != "") $message .= "Multi Locations: ".$_POST['multiLocations']."<br>"; $footer = "<br><br>--<BR>".$website; $html_text = ""; $html_text=" <HTML> <BODY> <p>$message</p><br> $footer </BODY> </HTML> "; mail($admin_email, $subject_admin_email, $html_text, $emailHeader); header("Location:http://onholdmusicsource.com/free/success.html"); exit; } else { print "Error: Invalid Music or voice options."; exit; } } else { print "Error: In-complete data."; exit; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242631-how-to-show-input-value-in-email-subject-line/#findComment-1246145 Share on other sites More sharing options...
AyKay47 Posted July 22, 2011 Share Posted July 22, 2011 from the looks of it, you can probably simply concatenate the company name onto the end of your $subject_admin_email variable.. if($_POST['companyName'] != "") $company_name = $_POST['companyName']; $message .= "Company: $comnay_name \n"; $subject_admin_email .= " $company_name"; Note: since mail is parsed as text, you will want to replace your breaks (<br>) with newlines.. (\n) like i have done above.. and in your headers, you will want to replace the (\n) with (\r\n) Quote Link to comment https://forums.phpfreaks.com/topic/242631-how-to-show-input-value-in-email-subject-line/#findComment-1246151 Share on other sites More sharing options...
imjeffw Posted July 22, 2011 Author Share Posted July 22, 2011 Thank You! worked beautifully I replaced the headers as suggested but went back to breaks as the /n didn't work (gave me all the info on one line) Quote Link to comment https://forums.phpfreaks.com/topic/242631-how-to-show-input-value-in-email-subject-line/#findComment-1246182 Share on other sites More sharing options...
AyKay47 Posted July 22, 2011 Share Posted July 22, 2011 glad it worked, should be a backslash not a forward slash Quote Link to comment https://forums.phpfreaks.com/topic/242631-how-to-show-input-value-in-email-subject-line/#findComment-1246187 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.