$formEmailAddress = $_POST['email']; //pull email address from the form data
$formTopic = $_POST['topic']; //pull topic from the form data
echo "
echo "
This page was created by PHP on the server and sent back to your browser.
";
//It will create a table and display one set of name value pairs per row
echo "
";
echo "";
foreach($_POST as $key => $value)
{
echo '';
echo '';
echo '';
echo "";
}
echo "
Field Name |
Value of field |
---|
',$key,' |
',$value,' |
";
echo "
";
$toEmail = "email"; //will send the email to the email address entered on the form
$subject = "Thank you for your message. I will contact you soon."; //This is the message that will be sent back to the person who sent you a message from your contact form.
$fromEmail = "address";
$emailBody = "Form Data\n\n ";
foreach($_POST as $key => $value)
{
$emailBody.= $key."=".$value."\n"; //Adds the name value pairs to the body of the email, each one on their own line
}
echo "
$emailBody
";
$headers = "From: $fromEmail" . "\r\n"; //Creates the From header with the appropriate address
if (mail($toEmail,$subject,$emailBody,$headers)) //puts pieces together and sends the email to your hosting account's smtp (email) server
{
echo("
Message successfully sent!
");
}
else
{
echo("
Message delivery failed...
");
}
?>