How to create a central PHP input validation file and use it?

Kit

New Member
I have some basic validation of some variables, but it is repeated on more than one page, how can I create a validation file and call it when needed? Here is some code:\[code\]$rep = '';$clean_rep = '';$rep = $_GET[rep];//Basic Variable Validationswitch ($rep){ case 'All': case 'Ian': case 'Mike': case 'Stan': case 'Gena': $clean_rep = $rep; break;}\[/code\]If I put this in a separate file and included it on the needed pages, I assume it would have to be in a function so it can be singled out:\[code\]validation.php:function validateRep($rep){ switch ($rep){ case 'All': case 'Ian': case 'Mike': case 'Stan': case 'Gena': $return("Clean"); break; }}\[/code\]once the variable is returned as "Clean", do I just assign $rep in the first script to $clean_rep? or is there a better procedure to doing this?
 
Back
Top