Can someone/ANYONE please PRETTY PLEASE help me with my validation of form input?
I am trying to fix my form so that if a person doesn't fill out a field, it will NOT post to Mysql, but instead give an error message and allow the person to go back and input the information.
Here is what I have so far but I'm getting an error when the form is not filled out and I click submit:
Parse error: syntax error, unexpected T_VARIABLE in /home..........
/* Validation */
function check_field1($reference)
{
if(!preg_match("/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\
]+$/s",$reference))
return TRUE;
else
return FALSE;
}
function check_field2($amount)
{
if(!preg_match("/[^0-9\ ]+$/",$amount))
return TRUE;
else
return FALSE;
}
function check_field3($name)
{
if(!preg_match("/[^0-9]+$/ ",$name))
return TRUE;
else
return FALSE;
}
function check_field4($cardtype)
{
if(!preg_match("/[^0-9]+$/ "$cardtype))
return TRUE;
else
return FALSE;
}
function check_field5($cardnumber)
{
if(!preg_match("/[^0-9]+$/ ",$cardnumber))
return TRUE;
else
return FALSE;
}
function check_field6($exp)
{
if(!preg_match("/[^0-9]+$/ ",$exp))
return TRUE;
else
return FALSE;
}
function check_field7($cvc2)
{
if(!preg_match("/[^0-9]+$/ ",$cvc2))
return TRUE;
else
return FALSE;
}
function check_field8($ssn)
{
if(!preg_match("/[^0-9]+$/ ",$ssn))
return TRUE;
else
return FALSE;
}
function check_field9($address)
{
if(!preg_match("/[^0-9]+$/ ",$address))
return TRUE;
else
return FALSE;
}
function check_field10($city)
{
if(!preg_match("/[^0-9]+$/ ",$city))
return TRUE;
else
return FALSE;
}
function check_field11($state)
{
if(!preg_match("/[^0-9]+$/ ",$state))
return TRUE;
else
return FALSE;
}
function check_field11($$zip)
{
if(!preg_match("/[^0-9]+$/ ",$zip))
return TRUE;
else
return FALSE;
}
function check_field11($email)
{
if(!preg_match("/[^0-9]+$/ ",$email))
return TRUE;
else
return FALSE;
}
function check_field11($phone)
{
if(!preg_match("/[^0-9]+$/ ",$phone))
return TRUE;
else
return FALSE;
}
/* Validation */
$error=0; // check up variable
/* get it checking */
if(!check_field1($reference))
{
echo "Illegal input $reference in 'Reference'";
$error++; // $error=$error+1;
}
if(!check_field2($amount))
{
echo "Illegal input $amount in 'Amount'";
$error++;
}
if(!check_field3($name))
{
echo "Illegal input $name in 'Name'";
$error++;
}
if(!check_field1($cardtype))
{
echo "Illegal input $cardtype in 'Cardtype'";
$error++; // $error=$error+1;
}
if(!check_field1($cardnumber))
{
echo "Illegal input $cardnumber in 'Cardnumber'";
$error++; // $error=$error+1;
}
if(!check_field1($exp))
{
echo "Illegal input $exp in 'Exp'";
$error++; // $error=$error+1;
}
if(!check_field1($cvc2))
{
echo "Illegal input $cvc2 in 'CVC2'";
$error++; // $error=$error+1;
}
if(!check_field1($ssn))
{
echo "Illegal input $ssn in 'SSN'";
$error++; // $error=$error+1;
}
if(!check_field1($address))
{
echo "Illegal input $address in 'Address'";
$error++; // $error=$error+1;
}
if(!check_field1($city))
{
echo "Illegal input $city in 'City'";
$error++; // $error=$error+1;
}
if(!check_field1($state))
{
echo "Illegal input $state in 'State'";
$error++; // $error=$error+1;
}
if(!check_field1($zip))
{
echo "Illegal input $zip in 'Zip'";
$error++; // $error=$error+1;
}
if(!check_field1($email))
{
echo "Illegal input $email in 'Email'";
$error++; // $error=$error+1;
}
if(!check_field1($phone))
{
echo "Illegal input $phone in 'Phone'";
$error++; // $error=$error+1;
}
if(!check_field1($initals))
{
echo "Illegal input $initals in 'Initals'";
$error++; // $error=$error+1;
}
if($error == 0)
{
echo
"
Thank You For Your Information!<p>
Your data:<br>
Your name: $your_name<br>
Your phone: $your_phone<br>
ZIP code: $your_zip
";
}else{
echo "Number of errors: $error";
}