Hello again everyone..

I have a form with an e-mail input. After the user enters their e-mail, I want to have the content of the form sent to them...
The name of the form textfield for the e-mail is "email".

How could I make this happen in the php script??

thank you!

6 Years
Discussion Span
Last Post by lwaterfo

You have a submit.php page (or whatever you want to call it) with the code to send the email.

You need to post the variables from your form.

Create a subject variable with your subject in it.

Create a message variable with your message in it.

Then you add the headers, and use the mail script.

Here's an example of a script:

$name = $_POST['name'];
$email = $_POST['email'];
$content = $_POST['message'];

$subject = 'Your Subject Goes Here';
$message = '
     <title>Email Response</title>
     From: '.$name.'<br>
     Message: '.$message.'
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: '.$email.' <'.$email.'>' . "\r\n";
// Mail it
mail($email, $subject, $message, $headers);


Hope this is helpful!


thx a lot :) this was helpful...one last thing, I have fields in my form that I want to display in the e-mail. how do I display the fields without using an html message? In other words, what would I place in between the single quotes below if I don't want to send an html message, but just regular text?

$message = ' ';

Your message would look like:

$message = ''.$variable1.'\n\n'.$variable2.'\n\n';

The "\n" is a single line break, so using two is like adding a paragraph tag.


grab the php variables using post then create a mail function

mail($email, $subject, $message);


I'm having some trouble with the message string..
I keep getting an error when I try to display the variables:

$message = ''.$mondayweek1.'\n\n'.$tuesdayweek1.'\n\n'.$wednesdayweek1.'\n\n'.$thursdayweek1.'\n\n'.$fridayweek1.'\n\n'.$saturdayweek1.'\n\n'.$sundayweek1.'\n\n'.$mondayweek2.'\n\n'.$tuesdayweek2.'\n\n'.$wednesdayweek2.'\n\n'.$thursdayweek2.'\n\n'.$fridayweek2.'\n\n'.$saturdayweek2.'\n\n'.$sundayweek2.'\n\n';

Can you find the error in this message code?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.