<?php
if (isset($_POST['submit'])) { // if the form was submitted.
echo ('<p>Form was submitted.</p>');
$date = date('F j, Y G:i:s');
$first = stripslashes ($_POST['firstname']);
$last = stripslashes ($_POST['lastname']);
$email = stripslashes ($_POST['email']);
$comment = stripslashes ($_POST['comments']);
$refer = getenv("HTTP_REFERER") ;
if (empty($first) && empty($last)
&& empty($email) && empty($comment)) {
echo ('<p>The form is blank. As is, the form will be ignored.</p>');
} else {
$mailto = "you@youremail.com";
$subject = "Guest Comment from YOUR WEB SITE.COM";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
$headers .= 'From: website guest <you@yourotheremail.com>' . "\r\n";
$body = "$date From: $refer.\n A guest, $first $last\n whose
return email is: $email\n has made this comment:\n $comment\n";
// mail($mailto,$subject,$body,$headers);
$guest_data = "$date\t$refer\t$first\t$last\n\t$email\n\t$comment\n";
if ($fp = @fopen ("guests.txt", "a")) { // Open
the file for writing.
fwrite ($fp, $guest_data);
fclose ($fp);
echo ('<p>Program executed O.K.</p>');
// echo ('<p>Info filed away in a tabbed array for future reference.</p>');
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Guest Comment</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<table bgcolor="#000000" align="center">
<tr><td colspan="2" align="center"><h2><font
color="#FFFFFF">Guest Comment</font></h2></td></tr>
<form name="guest_comment_form" action="commentz.php"
method="post">
<tr><td align="right"><font color="#FFFFFF">First
Name</td>
<td align="left"><input type="text" name="firstname"
size="25" maxsize="20"> </td></tr><tr>
<td align="right"> <font color="#FFFFFF">Last
Name</td>
<td align="left"><input type="text" name="lastname"
size="25" maxsize="20"></td></tr>
<tr><td align="right"><font color="#FFFFFF">Email
Address</td>
<td align="left"><input type="text" name="email"
size="25" maxsize="60""></td></tr>
<tr><td align="right"><font color="#FFFFFF">Comments
or Questions</td>
<td align="left"><textarea name="comments"
rows="4" cols="40"></textarea></td></tr>
<tr><td align="center" colspan="2"><input
type="submit" name="submit" value="Submit!">
<input type="reset" name="Reset" value="Reset"></td>
</tr>
</table>
</form>
</body></html>
|