Jump to content

[SOLVED] Forms Question - Adding Variables to the $Subject


Knightfall

Recommended Posts

I'm making an online form, and it's complete and working fine, but I'd like to add one last thing.

 

I'd like to add the person's name to the Subject of the e-mail.

 

To start off with, I know next to nothing about PHP.  If I hadn't been able to find a website that created the basic code that I could figure out and modify, I wouldn't be able to do this at all.

 

This is what I've got so far, and I was hoping I could get some kind soul to tell me what I'm doing wrong.

 

$Subject = "Dealer Location Request - ".$FirstName." ".$LastName;

The code I'm using to send the e-mail (in case it matters) is:

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

 

So far this is only returning "Dealer Location Request - " in the subject line, and I'd like to have it put the person's First and Last name in there as well... as added from the form itself.  I'm certain that it must be possible, I just can't figure out how to 'stick' it on there.

 

Any help would be appreciated, and thanks in advance ;)

 

$Subject = "Dealer Location Request - ".$FirstName." ".$LastName;

 

This code is fine, the variables $FirstName and $LastName must be empty.

 

Try this

 

$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];

$Subject = "Dealer Location Request - ".$FirstName." ".$LastName;

 

Where $_POST['FirstName']  ( FirstName bust be the same as the submitted form field name ): for example

 

<input type="text" name="FirstName">

Ah THANK YOU!

 

I did have the '&_Post' commands in there, but they were after the '$Subject'; and thus, as you said... empty

 

I've moved the one $Subject line down below the '&_Post' ones and everything is golden.

 

Thank you again glenelkins!

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.