<?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") ;
$mailto = "you@youremail.com";
$mailfrom = "From: YOUR_WEBSITE.COM";
$subject = "Guest Comment";
$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,$mailfrom);
echo ('<p>Program executed O.K.</p>');
} else {
?>
<!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="comment2x.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>
<?php
}
?> |
Click here to return to page 2 of the third tutorial.
Your IP address is:
38.103.63.59