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 contact@mydomain.org. 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='contact@mydomain.org';
$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
Share on other sites


<?
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='contact@mydomain.org';
$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.