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["vorname"])) $HTTP_POST_VARS["vorname"]="";
if (empty($err_vorname)) $err_vorname=" ";
if (empty($HTTP_POST_VARS["nachname"])) $HTTP_POST_VARS["nachname"]="";
if (empty($err_nachname)) $err_nachname=" ";
if (empty($HTTP_POST_VARS["strasse"])) $HTTP_POST_VARS["strasse"]="";
if (empty($err_strasse)) $err_strasse=" ";
if (empty($HTTP_POST_VARS["plz"])) $HTTP_POST_VARS["plz"]="";
if (empty($err_plz)) $err_plz=" ";
if (empty($HTTP_POST_VARS["ort"])) $HTTP_POST_VARS["ort"]="";
if (empty($err_ort)) $err_ort=" ";
if (empty($HTTP_POST_VARS["telefon"])) $HTTP_POST_VARS["telefon"]="";
if (empty($err_telefon)) $err_telefon=" ";
if (empty($HTTP_POST_VARS["fax"])) $HTTP_POST_VARS["fax"]="";
if (empty($err_fax)) $err_fax=" ";
if (empty($HTTP_POST_VARS["email"])) $HTTP_POST_VARS["email"]="";
if (empty($err_email)) $err_email=" ";
if (empty($HTTP_POST_VARS["text"])) $HTTP_POST_VARS["text"]="";
if (empty($err_text)) $err_text=" ";
$checked = true;
if (isset($HTTP_POST_VARS["submit"]))
{
check_len($checked, $HTTP_POST_VARS["vorname"],40,$err_vorname,"Eingabe zu lang! Maximale Länge:40",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["nachname"],80,$err_nachname,"Eingabe zu lang! Maximale Länge:80",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["strasse"],80,$err_strasse,"Eingabe zu lang! Maximale Länge:80",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["plz"],8,$err_plz,"Eingabe zu lang! Maximale Länge:80",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["ort"],80,$err_ort,"Eingabe zu lang! Maximale Länge:8",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["telefon"],80,$err_telefon,"Eingabe zu lang! Maximale Länge:80",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["fax"],80,$err_fax,"Eingabe zu lang! Maximale Länge:80",0,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_len($checked, $HTTP_POST_VARS["email"],80,$err_email,"Eingabe zu lang! Maximale Länge:80",1,"Eingabe erforderlich! Mindesteingabe Länge:1");
check_mail($checked, $HTTP_POST_VARS["email"], $err_email,"Die e-Mail enthält ungültige Zeichen oder ist unvollständig.", "Die e-Mail enthält Leerzeichen.");
check_len($checked, $HTTP_POST_VARS["text"],1000,$err_text,"Eingabe zu lang! Maximale Länge:1000",1,"Eingabe erforderlich! Mindesteingabe Länge:1");
}
if ( empty($HTTP_POST_VARS["submit"]) or (!$checked) )
{
?>