<?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 {
if (eregi("MIME-Version:",$first)
|| eregi("multipart/",$first) || eregi("\n",$first)
|| eregi("{",$first) || eregi("\r",$first) ||
eregi("}",$email) || eregi("@",$first) || eregi("<",$first)
|| eregi(";",$first) || eregi("\;",$first) ||
eregi("%0a",$first) || eregi("%0d",$first) ||
eregi("bcc:",$first) || eregi("cc:",$first) ||
eregi("to:",$first) || eregi("content-type:",$first)
)
{
die("<p>To prevent someone from spamming from the firstname
section of this form, certain special characters and phrases trigger
this form to shut down. The special characters and phrases appear
after the following equal sign. If nothing suspicious shows immediately
after the equal sign, the missing characters are in machine language
or are coded characters - characters like the greater than symbol
(>), the less than symbol (<), info enclosed within
these symbols ... Invalid additional input = $first. Missing characters
may include <?php, <body>, </html>,
etc.</p>");
}
if (eregi("MIME-Version:",$last) || eregi("multipart/",$last)
|| eregi("\n",$last) || eregi("{",$last) || eregi("\r",$last)
|| eregi("}",$email) || eregi("@",$last) || eregi("<",$last)
|| eregi(";",$last) || eregi("\;",$last) || eregi("%0a",$last)
|| eregi("%0d",$last) || eregi("bcc:",$last) ||
eregi("cc:",$last) || eregi("to:",$last) || eregi("content-type:",$last)
)
{
die("<p>To prevent someone from spamming from the lastname
section of this form, certain special characters and phrases trigger
this form to shut down. The special characters and phrases appear
after the following equal sign. If nothing suspicious shows immediately
after the equal sign, the missing characters are in machine language
or are coded characters - characters like the greater than symbol
(>), the less than symbol (<), info enclosed within
these symbols ... Invalid additional input = $last. Missing characters
may include <?php, <body>, </html>,
etc.</p>");
}
if (eregi("MIME-Version:",$email) || eregi("multipart/",$email)
|| eregi("\n",$email) || eregi("{",$email) ||
eregi("\r",$email) || eregi("}",$email) || eregi("<",$email)
|| eregi(";",$email) || eregi("\;",$email) ||
eregi("%0a",$email) || eregi("%0d",$email) ||
eregi("bcc:",$email) || eregi("cc:",$email) ||
eregi("to:",$email) || eregi("content-type:",$email)
)
{
die("<p>To prevent someone from spamming from the email
section of this form, certain special characters and phrases trigger
this form to shut down. The special characters and phrases appear
after the following equal sign. If nothing suspicious shows immediately
after the equal sign, the missing characters are in machine language
or are coded characters - characters like the greater than symbol
(>), the less than symbol (<), info enclosed within
these symbols ... Invalid additional input = $email. Missing characters
may include <?php, <body>, </html>,
etc.</p>");
}
if (eregi("MIME-Version:",$comment) || eregi("multipart/",$comment)
|| eregi("\n",$comment) || eregi("{",$comment)
|| eregi("\r",$comment) || eregi("}",$email) ||
eregi("<",$comment) || eregi(";",$comment)
|| eregi("\;",$comment) || eregi("%0a",$comment)
|| eregi("%0d",$comment) || eregi("bcc:",$comment)
|| eregi("cc:",$comment) || eregi("to:",$comment)
|| eregi("content-type:",$comment) )
{
die("<p>Please find another way of making your comment.
To prevent someone from spamming from the comment section of this
form, certain special characters and phrases trigger this form to
shut down. The special characters and phrases appear after the following
equal sign. If nothing suspicious shows immediately after the equal
sign, the missing characters are in machine language or are coded
characters - characters like the greater than symbol (>), the
less than symbol (<), info enclosed within these symbols ...
Invalid additional input = $comment. Missing characters may include
<?php, <body>, </html>,etc.</p>");
}
$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: you <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="comment4.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>
|