Use a form field to get email subject also

I have created a contact me form on my website using the below site:

That works great for a feedback scenario or a generic email scenario.  However, I would like to use that form to submit emails to my wordpress BLOG & to keep them simple.  That said, instead of having a static email subject specified in the PHP file, I need to develop a form that prompts for a subject & then uses that as the subject of the email.  Also, I would like to clean up the email body so that it only shows what they have written instead of everything else (I am sure that I can do that fairly easy).

Can anyone give me some pointers on what I would need to change so that the subject of the email is received from the HTML form?  Thanks!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Not sure if this is what you are looking for (I originally posted the code below here: )
$name = isset($_REQUEST['name']) ? stripslashes(htmlspecialchars($_REQUEST['name'])) : "";
$email = isset($_REQUEST['email']) ? stripslashes(htmlspecialchars($_REQUEST['email'])) : "";
$comments = isset($_REQUEST['comments']) ? stripslashes(htmlspecialchars($_REQUEST['comments'])) : "";
if( $name && $email && $comments )
	$to      = '';
	$subject = 'the subject';
	$headers = 'From:' . "\r\n" .
    'Reply-To:' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    	$message = "Name: $name\nEmail: $email\nComments:$comments";
	mail($to, $subject, $message, $headers);
	echo ("Your information was submitted successfully.");
	echo ('<?xml version="1.0" encoding="UTF-8"?>');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<title>Comment Form</title>
	if(isset($_REQUEST['Submit']) && $_REQUEST['Submit']=="Submit")
		echo("You must complete all the fields on the form below.");
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
			<td><input type="text" name="name" value="<?php echo $name;?>"></td>
			<td><input type="text" name="email" value="<?php echo $email;?>"></td>
			<td><textarea name="comments" rows="10" cols="65"><?echo $comments;?></textarea></td>
		<tr><td colspan="2"><input type="submit" name="Submit" value="Submit"/></td></tr>

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rustyrpageAuthor Commented:
So how would I put that on my website?  Is it just a single PHP file that does it all for me?
rustyrpageAuthor Commented:
Okay, I got it as a PHP file & that works fine (had that working before)...however, the key is that I would like to have a SUBJECT box in the form so that people can put in the subject of the email.  (as that will become the title of the post in Wordpress.
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

rustyrpageAuthor Commented:
Sorry, tons of posts in a row here...I would also need the FROM to be the same as the sender (the email field in the form).
rustyrpageAuthor Commented:
Got the subject to change by telling the subject to be equal to the name field (since I don't need the name field), but now I am having these issues (sorry, I am certainly a beginner here, but appreciate your help!):

1) The from address needs to be the same as the one in the form
2) The body needs to have only the content of the comments section (no header or other information.

This will be used primarily for a person to go to a link on my website & fill out the form with their email address, the subject of the post & the body of the post, when they hit submit, it will go to the Wordpress blog & create a new post on the website.

Please let me know if that makes any sense at all.

rustyrpageAuthor Commented:
I found a different solution to this....but thanks for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.