I am trying to use form validation to verify a zip code:
<?php
if (($_POST["zip_code"] == "") || (!ereg("^\d{5}$",($_POST["zip_code"])))) {
$errors['zip_code']="<font color='red'>*</font>";
}
?>
Even if I fill out the zip code section of the form with a five digit number it will not process the form. Instead it echos the error "Zip Code*" which is right... if I didn't enter 5 digits or I entered AAAAA. But since I entered five numbers it should process.
This is my first time trying to use regex but it appears "\d{5}$" is right for a zip code. Maybe I have it placed in the form incorrectly?
Thanks in advance for any help or suggestions.