Add name to subject line in a submitted form

Is there a way to add form variables into the subject line from a contact form…

indent preformatted text by 4 spaces
    $to = 'you@yourdomain.com';
    $from = 'From: user@domain.com';
    $subject = 'Support request from ".$_POST["$FirstName"] in ".$_POST["$Dept"];

Yes, as you’ve done above. Although you’ve mixed the quotes up in that last line so it won’t parse properly.

You might want to read this http://securephpwiki.com/index.php/Email_Injection too.

Thanks I got it figured out.

.$FirstName." in ".$Dept;

What is odd though is I had to use quote character instead of the apostrophe at the start.

"Support request from “.$FirstName.” in ".$Dept;

Well, you have to be consistent. In your first code you’d opened with a single-quote or apostrophe, but then used double-quotes for the rest of the line.

'Support request from ' . $FirstName . ' in ' . $Dept;
"Support request from " . $FirstName . " in " . $Dept;
"Support request from $FirstName in $Dept";

should all be OK.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.