Email Handling PHP
- April 17, 2009
- 3 replies
- 811 views
Hi,
I had such awesome help the last time I posted I have no doubt that someone can help me here. I tried a tutorial on creating an email form and sending the data by php. I followed everything he did on the video and posted the form and php on my server to test. I worked for the most part when I entered the information for the form and sent it, it displayed a response back the the email went through, it showed up in my email box but the From field in the display didn't look correct plus it didn't display the information in the fields. I'm going to include a screen shot of the email and the code below. Hopefully someone can help. Thanks.
Don
<?php
/* Subject and Email Variables */
$emailSubject = 'Crazy PHP Scripting';
$webMaster = 'dggrafix@earthlink.net';
/* Gathering data Variables */
$emailField = $_POST['email'];
$nameField = $_POST['name'];
$phoneField = $_POST['phone'];
$budgetField = $_POST['budget'];
$travelersField = $_POST['travelers'];
$commentsField = $_POST['comments'];
$newsletterField = $_POST['newsletter'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Budget: $budget <br>
Number of Travelers: $travelers <br>
Comments: $comments <br>
Newsletter: $newsletter <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>JakesWorks - travel made easy-Homepage</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>