PHP Script - Thanks for any help!?

robert b

New member
I am try validate the zip code... The point is let the user know if we work or not in their zip code!

I have two files so far but its not working... keep returning "Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE in ..."

I have try many others way to make this happen but I don't have that much skill to make work...

1st file: form.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form action="error.php" method="post">
<table>
<tr><td>Zip code:</td><td>
<input type="text" name="zipcode"></td></tr>
</table>
<br>
<input type="submit" onSubmit ="return validateZIP(this.ZipCode.value)">
</form>
</body>
</html>

2nd file: error.php
<?php
function validateZIP(field)
{
if $_POST[$field] == "" {
echo "$field is empty";
return false; }

$fields = array('77070', '77373', '77380');

foreach ($fields as $zip) {
if($_POST[$field] == $zip)

return true;
}
echo "Zip code is incorrect.";
return false;
}
?>
 
Back
Top