I have a form which contains a dynamic number of text fields that are intended for shoppers to input a positive number only. I separated the validation into a function. It is working well for me so far, but given that security is such a major concern I thought I would ask for comments from the forum. Here's the function:
function validate($array){
if (count($array) > 0) {
foreach($array as $product){
if(is_numeric($product[0]) && $product[0] >= 0){
return true;
}
else{
return false;
}
}
}
}
When the form is sent, the returning page does a little bit of it's own configuring; functions relevant to the page itself and the user's context. Then the script checks to see if input was sent. Then it validates the data before attempting to use it. There are even checks further down in the script that continue to compare it as though it is numeric, and that it is greater than or equal to zero.
Is this sufficient?