Jump to content

How to show input value in email subject line


imjeffw

Recommended Posts

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

 

 

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 = "[email protected], [email protected]";
$emailFrom = "[email protected]";
$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;
}
?>

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.