Hi, 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:
$rep = '';
$clean_rep = '';
$rep = $_GET[rep];
//Basic Variable Validation
switch ($rep){
case 'All':
case 'Ian':
case 'Mike':
case 'Stan':
case 'Gena':
$clean_rep = $rep;
break;
}
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:
validation.php:
function validateRep($rep){
switch ($rep){
case 'All':
case 'Ian':
case 'Mike':
case 'Stan':
case 'Gena':
$return("Clean");
break;
}
}
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?