Please sign our guestbook.
Please sign our guestbook.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Intro to PHP</title>
<link href="phpwk4.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="head">
<h1>INTRODUCTION TO PHP - WEEK 6</h1>
</div>
<?php
include ("phpleftnav.inc");
?>
<div id="content">
<div id="formbox1">
<div id="formbox2">
<div id="formbox3">
<?php
//read in form variables
$name = stripslashes($_POST["name"]);
$user_mail = stripslashes($_POST["user_mail"]);
$comments = stripslashes($_POST["comments"]);
//initialize variables
$file_name = "phpwk6text.txt";
$replace_data = " ";
$string_data1 = "$name";
$string_data2 = "$user_mail";
$string_data3 = "$comments";
include ("phpwk6variables.inc");
include ("phpwk6functions.inc");
//check to see if all data entered
if (!empty($name) && !empty($user_mail) && !empty($comments)) {
if ((strlen($name)) > $len_name) { //check length of name
echo "<p>Your name is too long. Please enter a shorter version.</p>";
$name="";
include ("phpwk6form.inc");
include ("phpwk6footer.inc");
die ();
}
foreach ( $_POST as $key => $value ) {
$postVars .= $value;
}
//check for spam characters
$postVars = strtolower($postVars);
if(ereg("mime-version",$postVars) || ereg("mime",$postVars) || ereg("bcc",$postVars) || ereg("cc",$postVars)) {
mail("$my_email", "Form Hijack Attempt", "A spam relay was attempted from $websitename and was blocked.", "From:SpamMonitor");
echo $postVars;
echo "<p align='center'>Sorry, no spam accepted.</p>";
include ("phpwk6footer.inc");
die();
}
//check for valid email address
if (validate_email($user_mail)) {
echo $valid;
} else {
echo "<p align='center'>Email is invalid!";
echo "Please enter a valid email address.</p>";
include ("phpwk6form.inc");
include ("phpwk6footer.inc");
exit;
}
//everything looks good - respond
mail ("$my_email", "$subject", "$businessmailmsg", "$headers");
echo "<p align='center'>Thank you for your comments!</p>";
include ("phpwk6printfile.inc");
} else {
//not all fields are filled out
echo "<p align='center'>Please sign our guestbook.</p>";
include ("phpwk6form.inc");
}
?>
<?php
include ("phpwk6footer.inc");
?>