I’m attempting to use filter_input_array() to validate some post data. Despite my best efforts the function seems to return null values inside of the $filter array(passing the condition) as opposed to failing the validation and returning false as I expect.
Here’s an example of the code implementation:
$filters = array(
'phone' => FILTER_VALIDATE_INT,
'email' => FILTER_VALIDATE_EMAIL
);
if(filter_input_array(INPUT_POST, $filters)){
//filters are validated insert to database
} else{
//filters are invalid return to form
}
No matter kind of bad data (phone=’a’, email='{}/!~’ for example) I enter the array is still returned instead of the function returning false and failing the condition. Any help would be greatly appreciated.
To keep the code the way you want it try this method