PHP E-Mail Form Code
Posted: Wed Sep 28, 2011 1:49 pm
I am new to php so please forgive me. I am using dreamweaver cs4 and I am trying to create a form that will send the responses to my email. I have the following code. The code brings up up the confirmation page and everything, but I never get the email. Any help would be greatly appreciated.
<?php
/* Subject and E-Mail Variables */
$emailSubject = 'Date and Location Request';
$webMaster = 'username@gmail.com';
/* Gather Data Variables */
$studentsnameField = $_POST['studentsname'];
$parentsnameField = $_POST['parentsname'];
$locationField = $_POST['location'];
$highschoolField = $_POST['highschool'];
$hearField = $_POST['hear'];
$dayphoneField = $_POST['dayphone'];
$eveningphoneField = $_POST['eveningphone'];
$emailField = $_POST['email'];
$body = <<<EOD
<br><hr><br>
Students Name: $studentsname <br>
Parents Name: $parentsname <br>
City / State: $location <br>
Nearest High School: $highschool <br>
How did you hear about the Workshops?: $hear <br>
Daytime Phone: $dayphone <br>
Evening Phone: $eveningphone <br>
E-Mail: $email <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>Deleted code to make easier to read</html>
EOD;
echo "$theResults";
?>
<?php
/* Subject and E-Mail Variables */
$emailSubject = 'Date and Location Request';
$webMaster = 'username@gmail.com';
/* Gather Data Variables */
$studentsnameField = $_POST['studentsname'];
$parentsnameField = $_POST['parentsname'];
$locationField = $_POST['location'];
$highschoolField = $_POST['highschool'];
$hearField = $_POST['hear'];
$dayphoneField = $_POST['dayphone'];
$eveningphoneField = $_POST['eveningphone'];
$emailField = $_POST['email'];
$body = <<<EOD
<br><hr><br>
Students Name: $studentsname <br>
Parents Name: $parentsname <br>
City / State: $location <br>
Nearest High School: $highschool <br>
How did you hear about the Workshops?: $hear <br>
Daytime Phone: $dayphone <br>
Evening Phone: $eveningphone <br>
E-Mail: $email <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>Deleted code to make easier to read</html>
EOD;
echo "$theResults";
?>