bjneiman Posted February 24, 2009 Share Posted February 24, 2009 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; ?> Link to comment https://forums.phpfreaks.com/topic/146707-solved-adding-form-content-to-an-email-subject-line/ Share on other sites More sharing options...
gevans Posted February 24, 2009 Share Posted February 24, 2009 <? 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! Link to comment https://forums.phpfreaks.com/topic/146707-solved-adding-form-content-to-an-email-subject-line/#findComment-770237 Share on other sites More sharing options...
bjneiman Posted February 24, 2009 Author Share Posted February 24, 2009 Well lookie there...that seemed to do the trick! I figured I had to define something to make it work. Didn't really know what though! Thanks gevans! Link to comment https://forums.phpfreaks.com/topic/146707-solved-adding-form-content-to-an-email-subject-line/#findComment-770271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.