include ("arrays.php");
if ($fname != "")
{
if(!ereg("^[-A-Za-z\.\ ]+$", $fname))
{
$fail .= "$fname is an invalid first name. \n";
}
}
else
{
$fail .= "Please enter your first name \n";
}
if ($lname != "")
{
if(!ereg("^[-A-Za-z\.\ ]+$", $lname))
{
$fail .= "$lname is an invalid last name. \n";
}
}
else
{
$fail .= "Please enter your last name \n";
}
if ($address != "")
{
if(!ereg("^[0-9A-Za-z\.\ ]+$", $address))
{
$fail .= "$address is an invalid address. ";
}
}
else
{
$fail .= "Please enter your street address \n";
}
if ($zip != "")
{
if(!ereg("^([0-9]{5})(-[0-9]{4})?$", $zip))
{
$fail .= "$zip is an invalid zip code. \n";
}
}
else
{
$fail .= "Please enter your zip code \n";
}
if ($city != "")
{
if(!ereg("^[-A-Za-z\.\ ]+$", $city))
{
$fail .= "$city is an invalid city name. \n";
}
}
else
{
$fail .= "Please enter your city \n";
}
if ($email != "")
{
if(!ereg("^([A-Za-z_\.]*)@([A-Za-z_]*)\.([A-Za-z_\.]*)$", $email))
{
$fail .= "$email is an invalid email address. ";
}
}
else
{
$fail .= "Please enter your email address \n";
}
if ($phone != "")
{
if(!ereg("^[0-9\ \(\)\-]+$", $phone))
{
$fail .= "$phone is an invalid phone number. ";
}
}
else
{
$fail .= "Please enter your phone number \n";
}
if ($comment != "")
{
eregi_replace("^[]$", "", $comment);
}
# save HTML code for the form
$form = <<
END_HTML;
# display the errors, if any ocurred
if ($fail != "")
{
echo $fail;
}
# display the form
echo $form;
?>