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!
-l.

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:

<?php 
$name = $_POST['name'];
$email = $_POST['email'];
$content = $_POST['message'];

$subject = 'Your Subject Goes Here';
	
$message = '
     <html>
     <head>
     <title>Email Response</title>
     </head>
     <body>
     From: '.$name.'<br>
     Message: '.$message.'
     </body>
     </html>';
	
// 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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.