All comments and personal details are kept in the strictest confidence.
function check_len(&$check, $field, $max, &$err_field, $err="", $min, $min_err="")
{
if (strlen($field) > $max)
{
if ($err == "")
{
$err = $msg->err_maxlen($max);
}
$err_field = $err;
if ($check==true) $check = false;
}
if (strlen($field) < $min)
{
if ($min_err == "")
{
$min_err = $msg->err_minlen($min);
}
$err_field = $min_err;
if ($check==true) $check = false;
}
}
function check_mail(&$check, $fld, &$error_field, $invalidchars="", $blanks="")
{
global $msg;
$expr = "^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z][a-z]+\$";
//echo "expr=" . $expr . "
";
if ((!$fld) || ($fld=="") || (!eregi($expr,$fld)))
{
if ($invalidchars > "")
{
$error_field = $invalidchars . "
\n";
} else {
$error_field = "invalid characters
\n";
}
if ($check==true) $check =false;
}
if (strrpos($fld,' ') > 0)
{
if ($blanks > "")
{
$error_field = $blanks . "
\n";
} else {
$error_field = "blanks in e-mail
\n";
}
if ($check==true) $check =false;
}
}
if (empty($HTTP_POST_VARS["name"])) $HTTP_POST_VARS["name"]="";
if (empty($err_name)) $err_name=" ";
if (empty($HTTP_POST_VARS["email"])) $HTTP_POST_VARS["email"]="";
if (empty($err_email)) $err_email=" ";
if (empty($HTTP_POST_VARS["address"])) $HTTP_POST_VARS["address"]="";
if (empty($err_email)) $err_email=" ";
if (empty($HTTP_POST_VARS["comment"])) $HTTP_POST_VARS["comment"]="";
if (empty($err_comment)) $err_comment=" ";
$checked = true;
if (isset($HTTP_POST_VARS["submit"]))
{
check_len($checked, $HTTP_POST_VARS["name"],30,$err_name,"Field too long! Maximum:30",0,"Field required! Minimum:1");
check_len($checked, $HTTP_POST_VARS["email"],80,$err_email,"Field too long! Maximum:80",1,"Field required! Minimum:1");
check_mail($checked, $HTTP_POST_VARS["email"], $err_email,"The e-mail contains invalid characters or is incomplete.", "The e-mail contains blanks.");
check_len($checked, $HTTP_POST_VARS["address"],100,$err_comment,"Address field too long! Maximum:100",0,"Field required! Minimum:1");
check_len($checked, $HTTP_POST_VARS["comment"],500,$err_comment,"Comment field too long! Maximum:500",0,"Field required! Minimum:1");
}
if ( empty($HTTP_POST_VARS["submit"]) or (!$checked) )
{
?>
