I'm posting this again because I cannot get this to work, and I really need someone's help.
I'm trying to validate form data in the $HTTP_POST_VARS array, and everything works o.k. except when I check certain fields to see if they are numbers. Here is my routine:
function validate_numbers(&$fields)
{
$errors = "";
global $HTTP_POST_VARS;
while( list($key,$val) = each($fields) )
{
$temp = $HTTP_POST_VARS[$val];
if( gettype($temp) != "integer" && gettype($temp) != "double" )
{
$errors .= "Field $val must be a number<br>";
}
}
return $errors;
}
the $fields is an array passed in that holds the names of form fields that should be
numbers. I don't really need the $key, just the $val to match it against the data from the POST. Even when I put numbers in the form fields and submit them, every field comes back invalid. I have also tried using is_long() and is_double() with the same results. I've also tried adding () in case I have a precedence problem.
Also, i couldn't get the the is_long(),is_double(), and gettype() functions to work directly on the HTTP_POST_VARS array, like is_int( $HTTP_POST_VARS[$val] ), so I set the $temp variable. Anyone know why this doesn't work?
TIA
Brian