
8:40:45 pm, Friday, November 21, 2008
Anita Scripter © 2007 - All Rights Reserved
<!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>PHP101 Week 4</title>
<link href="phpwk4.css" rel="stylesheet" type="text/css" />
<?php
$dname = "sliloh.com"; //my domain
$mename = "Sliloh Graphics"; //me name
?>
<title><?php echo $mename?> Contact Form</title>
</head>
<body>
<h1 id="head">Week Four PHP</h1>
<?php
// include Content
include ("content.inc");
?>
<p class="center"><?php
echo date("g:i:s a, l, F j, Y ");
?></p>
<div id="box">
<div class="innards">
<?php
//Read in variables
$name = stripslashes($_POST["name"]);
$user_mail = stripslashes ($_POST["user_mail"]);
$phone = stripslashes ($_POST["phone"]);
$comments = stripslashes ($_POST["comments"]);
include("variables.inc");
include("functions.inc");
//Check to see if the required data has been entered
if (!empty($name) && !empty($user_mail) && !empty($comments)) {
//check the length of name & phone
if ((strlen($name)) > $len_name) {
// if input > size limit
echo "<p class='in'>Is your name Rumplestiltskin or what!? Use a nickname, sheesh!</p>";
$name = "";
include ("form.inc");
die();
}else if ((strlen($phone)) > $len_phone) {
// if input > size limit
echo "<p class='in'>Dats too many numbers, try again!.</p>";
$phone = "";
include ("form.inc");
die();
}else {
// for testing purposes
echo "<p class='in'>It's a working $name!</p>";
}
////////////////////////////////////////////////////
// Combine all the data into one variable
foreach ( $_POST as $key => $value ) {
$postVars .=$value;
}
//convert variable to lower case letters for easier testing
$postVars = strtolower($postVars);
//statement checks data is in $postVars variable
//or script will die.
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 $dname and was blocked.");
echo "<p class='in'>Get a life lameo</p>";
die();
}
// validate_email, send error message
if (validate_email($user_mail)) {
echo $valid;
echo "<p class='in'>E-mail is valid</p>";
} else {
echo "<p class='in'>E-mail is invalid! ";
echo "Please enter a valid e-mail address.</p>";
include("form.inc");
exit;
}
//End statement
mail("$my_email", "$subject", "$mybiz", "$headers");
mail("$user_mail", "$subject", "$usermailmsg", "$headers");
include("thanks.inc");
} else {
include("form.inc");
}
?>
<h3><a href="http://www.sliloh.com">Home</a></h3>
</div>
</div>
<?php
include ("footer.inc");
?>