Jump to content

[SOLVED] Adding form content to an email subject line


bjneiman

Recommended Posts

I know this is such a simple question...but I'm trying to learn a little bit more about web development after a guy built us a website for our non-profit.

 

Our Contact Us page takes submissions through a web form and emails it to [email protected]. How do you get the subject line to read: Contact Us - txtname (where txtname is actually the form value that was submitted) I am assuming it is this line that needs changing:

@mail($to_email,"Contact Us",$content,$hdr);

 

This and several dozen variations of the same is what did not work:

@mail($to_email,"Contact Us + txtname",$content,$hdr);

@mail($to_email,"Contact Us" + .$_REQUEST['txtstate'].,$content,$hdr);

 

 

This is the current page code for submitcontctus.php


<?
include 'admin/includes/connection.php';


$sqlstr = "insert into cc_contact (contact_name,contact_phone,contact_email,contact_msg) values ('".$_REQUEST["txtname"]."','".$_REQUEST["txtphone"]."','".$_REQUEST["txtemail"]."','".mysql_real_escape_string($_REQUEST["comments"])."')";
//echo $sqlstr;exit;
mysql_query($sqlstr);
$me="Your Details Successfully Sent";

$to_email='[email protected]';
$from_email=$_REQUEST["txtemail"];

$hdr = "MIME-Version: 1.0\n";
$hdr .= "From: {$from_email} \n";

$content ="Name : ".$_REQUEST['txtname']."\n";
$content .="State : ".$_REQUEST['txtstate']."\n";
$content .="Email : ".$_REQUEST['txtemail']."\n";
$content .="Message :\n".$_REQUEST['comments']."\n";

[b]@mail($to_email,"Contact Us",$content,$hdr);[/b]
header("location: contactus.php?mess=$me");
exit;

?>


<?
include 'admin/includes/connection.php';


$sqlstr = "insert into cc_contact (contact_name,contact_phone,contact_email,contact_msg) values ('".$_REQUEST["txtname"]."','".$_REQUEST["txtphone"]."','".$_REQUEST["txtemail"]."','".mysql_real_escape_string($_REQUEST["comments"])."')";
//echo $sqlstr;exit;
mysql_query($sqlstr);
$me="Your Details Successfully Sent";

$to_email='[email protected]';
$from_email=$_REQUEST["txtemail"];

$hdr = "MIME-Version: 1.0\n";
$hdr .= "From: {$from_email} \n";

$content ="Name : ".$_REQUEST['txtname']."\n";
$content .="State : ".$_REQUEST['txtstate']."\n";
$content .="Email : ".$_REQUEST['txtemail']."\n";
$content .="Message :\n".$_REQUEST['comments']."\n";

$subject = "Contact Us - ".$_REQUEST['txtname'];

@mail($to_email,$subject,$content,$hdr);
header("location: contactus.php?mess=$me");
exit;

?>

 

That should do it, have a look at the little change I made!

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.