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 ;)

 

Link to comment
Share on other sites

$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">

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.