Knightfall Posted October 11, 2007 Share Posted October 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72791-solved-forms-question-adding-variables-to-the-subject/ Share on other sites More sharing options...
glenelkins Posted October 11, 2007 Share Posted October 11, 2007 $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"> Quote Link to comment https://forums.phpfreaks.com/topic/72791-solved-forms-question-adding-variables-to-the-subject/#findComment-367110 Share on other sites More sharing options...
Knightfall Posted October 11, 2007 Author Share Posted October 11, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/72791-solved-forms-question-adding-variables-to-the-subject/#findComment-367116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.