1,
"First name" => 1,
"Adress" => 1,
"email" => 2,
"Zip Code" => 3,
"Phone" => 4,
"Website" => 5
);
# Fill in the number of field include the textfield if you switch it on.
# E.g. Name + First Name + Textfield = 3
# If this number is wrong, the form wont be send.
$k = "8";
# the size of input fields
$inputsize = 20;
# switch this on (1) or off (0)
$send_ip = "0"; // will send you the IP Adress of the sender
$f5 = "1"; // allow or disallow to reload the page
// switch this off "0" if you get many doubled mails
# configure the mailcheck (option 2)
$str = ":\/,\""; // invalid character in the email (dont change if you dont know how)
$lengthm = 8; // minimal lentgh of the email, eg@eg.com = 9
# configure the Zip Code check (option 3)
$plz_len = 5; // exact lenght of the common Zip Code
$plz_min = 00000; // start of Zip Code area
$plz_max = 99999; // end of Zip Code area
# configure the check routine of phonenumber (option 4)
$phone_max = 16; // maximale länge der Telefonnummer
$phone_min = 3; //mindestlänge der Telefonnummer
# switch $textarea to 1 if you need a textarea
# $textarea = 0 to switch off the textarea
$textarea = 1;
# configure the textarea
$laengen = 400; // maximal number of characters in the textarea
$textlabel ="message"; // set the textlabel
$textheadline = "Your message"; // set the textheadline
$rows = 5; // number of rows (height)
$cols = 40; // number of colums (width)
# fill in the receiver adress
$receiver = 'info@yourdomain.com';
$reference = 'contactform';
$from = 'info@yourdomain.com';
# If you get any errors, try to fill in your mail adress (of your domain).
# z.B. name@yourdomain.com
$add = "";
# define browsertitel
$browsertitel = "Contactform";
# define backgroundcolor
$background = "#ffffff";
# define textcolor
$textcolor = "#000000";
# define errorcolor
$errorcolor = "#FF0000";
# define the backgroundcolor of the inputfields
$inputcolor = "#ffffff";
# define the bordercolor
$bordercolor = "#000000";
# define the borderstyle eg. none, dotted, dashed, solid, double, groove, ridge, inset, outset
$borderstyle = "dashed";
# define borderwidth
$borderpx = "1";
# define the formwidth
$borderwidth = "450";
# headline
$headline = "
Contactscript Version 1.3
";
######################################################################################################
# end of configuration #
######################################################################################################
$check = count($fields);
if ($textarea == 1) {
$check = $check + 1;}
if ($k != $check){
echo 'The variable $k in line 47 is wrong. You have to use '.$check.' instead of'.$k;
}
######################################################################################################
# Please dont change anything if you dont know what u do. #
############################################# check content ##########################################
$ip = $send_ip == "0" ? $ip="" : getenv('REMOTE_ADDR');
if (($textarea == "1") && isset($_POST['send']))
{
$i="1";
$messagel = strlen($_POST["send"]["$textlabel"]);
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$textlabel"] = stripslashes($_POST["send"]["$textlabel"]);
}
} else{$i="0";}
if (isset($messagel) && $messagel > $laengen)
{
$fmessage = "The maximum lenght of the message is ".$laengen." character. The message has ".$messagel." character. ";
$i--;
} else{ $fmessage = ""; }
$fempty = array();
if (isset($_POST['send']) && is_array($_POST["send"]))
{
foreach ($fields as $var =>$check)
{
switch ($check)
{
case "0":
#do nothing / no check
$i++;
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
$_POST["send"]["$var"] = htmlspecialchars($_POST["send"]["$var"]);
break;
case "1":
#not empty
if(empty($_POST["send"]["$var"]))
{
$fempty["$var"] = "$var must not be empty! ";
}
else
{
$i++;
$_POST["send"]["$var"] = htmlspecialchars($_POST["send"]["$var"]);
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
}
break;
case "2":
#check mail
if ((strcspn($_POST['send']["$var"], $str) < $lengthm) OR
(substr_count($_POST['send']["$var"], "@") < 1) OR
(substr_count($_POST['send']["$var"], ".") < 1))
{
$fmail = "The E-Mail is invalid! ";
}
else
{
$i++;
$fmail = "";
}
break;
case "3":
#check zip code
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
if ( !is_numeric($_POST['send']["$var"]) || ( strlen(strval($_POST['send']["$var"])) != $plz_len ))
{
$fplz = "The zip code is invalid! " ;
}
elseif ( ( $_POST['send']["$var"] < $plz_min ) || ( $_POST['send']["$var"] > $plz_max ) )
{ $fplz = "The zip code is out of the allowed range! " ;
}
else
{
$i++;
$fplz="";
}
break;
case "4":
#check phonenumber
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
if ( !is_numeric($_POST['send']["$var"]) || ( strlen(strval($_POST['send']["$var"])) > $phone_max ) || ( strlen(strval($_POST['send']["$var"])) < $phone_min ))
{
$fphone = "The phone number is invalid! " ;
}
else
{
$i++;
$fphone="";
}
break;
case "5":
#check website
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
$search = '/^[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}$/i';
$else_search = '/^(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}$/i';
if (preg_match($search,$_POST['send']["$var"]) || preg_match($else_search,$_POST['send']["$var"]))
{
$fweb = "";
$i++;
}
else
{
$fweb = "The domain is invalid! ";
}
break;
case "6":
#check only letters
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
$search = '/[a-zA-Z]/i';
if (!preg_match($search,$_POST['send']["$var"]))
{
$fempty["$var"] = "$var must contain only letters! ";
}
else
{
$fempty["$var"] = "";
$i++;
}
break;
case "7":
#check nur Zahlen
if (get_magic_quotes_gpc() == "1")
{
$_POST["send"]["$var"] = stripslashes($_POST["send"]["$var"]);
}
if (!is_numeric($_POST['send']["$var"]))
{
$fempty["$var"] = "$var must contain only numbers! ";
}
else
{
$i++;
$fempty["$var"]="";
}
break;
}
}
}
############################################# END of check #########################################
######################################################################################################
# Please dont change anything if you dont know what u do. #
# The following code is to format the mail #
######################################################################################################
if (strtoupper(substr(PHP_OS,0,3)=='WIN'))
{
$ret="\r\n";
}
elseif (strtoupper(substr(PHP_OS,0,3)=='MAC'))
{
$ret="\r";
}
else
{
$ret="\n";
}
################################## format the headers #########################################
foreach ($fields as $field => $value)
{
if ($value == 2)
{
$reply_val = $field;
}
}
$reply = isset($_POST['send']["$reply_val"]) ? $_POST['send']["$reply_val"] : "";
$header .= 'From: contactform <'.$from.'>'.$ret;
$header .= 'Reply-To: '.$reply.$ret;
$header .= 'Return-Path: '.$reply.$ret;
$header .= "Message-ID: ".$ret;
$header .= "X-Mailer: PHP v".phpversion().$ret;
$mime=md5(time());
$headers .= 'MIME-Version: 1.0'.$ret;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime."\"".$ret;
#
#####################################################################################################
# Check variables #
#####################################################################################################
if (isset($_POST['send']) && is_array($_POST["send"]) && $i==$k){
foreach ($_POST['send'] as $key => $value)
{
$content .= $key.": ".$value.$ret;
}
######################################################################################################
# Bitte ändern Sie hier nichts, es sei denn Sie wissen genau was Sie tun. #
# Hier wird der Inhalt gesendet #
######################################################################################################
if(empty($add))
{
$add = "";
if (@mail($receiver, $reference, "The IP adress of the sender is: ".$ip.$ret.$content, $header))
{
$status = "