// form not yet submitted
// display initial form
if (!isset($_POST['submit']))
{
?>
}
else
{
//Setup variables
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
// set up error list array
$errorList = array();
$count = 0;
// validate text input fields
if (!$name) { $errorList[$count] = "Invalid entry: Name"; $count++; }
if (!$email) { $errorList[$count] = "Invalid entry: Email Address"; $count++; }
if (!$comments) { $errorList[$count] = "Invalid entry: Comments"; $count++; }
// check for errors
// if none found...
if (sizeof($errorList) == 0)
{
/* Email Name from Form */
$nameFromForm = strtolower($_POST['name']) ;
/* Event Email Address from Form */
$emailFromForm = $_POST['email'] ;
/* Event Commnets from Form */
$commentsFromForm = $_POST['comments'] ;
/* Remote Address */
$ip = strtolower($_SERVER['REMOTE_ADDR']);
/* Remote Host */
$remhost = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
/* recipients */
$to = "webmaster@pathix.com";
/* subject */
$emailsubject = "Pathix Web Site Feedback";
/* date */
$regdate = date ("l dS of F Y h:i:s A");
/* message */
$message = "
Pathix Web Site - Feedback Submission
The following feedback has been submitted from the Pathix Web Site. Details are as follows:
| Name: |
|
$nameFromForm |
| Email: |
|
$emailFromForm |
| Comments: |
|
$commentsFromForm |
| Host Name / IP Address: |
|
$remhost / $ip |
| Date/Time: |
|
$regdate |
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "From: Pathix Web Site \r\n";
/* and now mail it */
mail($to, $emailsubject, $message, $headers);
echo "Thank you for your submission. ";
echo " Should you require a response, you will be contacted in 1 business day. ";
echo "
";
echo " Click here to return to the main page. ";
}
else
{
// errors found
// print as list
echo " The following errors were encountered: ";
echo " ";
for ($x=0; $x$errorList[$x]";
}
echo " ";
echo "
";
echo "Please contact the site administrator with this error. ";
}
}
?>
|
|