Basic Form Validation of Integer Input
Posted: Sat Jan 22, 2011 3:36 pm
I'm having some trouble validating an entry to my form. When i enter a valid number such as 3285 i get the first error message ([7]) returned. I can't find anything wrong with my code so if anyone could point me in the right direction it would be appreciated. I have only been doing PHP for 2 weeks so it may be something simple for which i apologise.
Here is my code:
Here is my unexpected output:
Here is my code:
Code: Select all
if ($POST['extension'] != strval(intval($_POST['extension']))) {
$errors[7] = 'Phone Extension must be a number';
} else {
if (($_POST['extension'] < 3000) || ($_POST['extension'] > 3599)) {
$errors[8] = 'Extension must be between 3000 and 3599';
}
}
Code: Select all
Phone Extension must be a number