Write a class to do it, start now, start today, don't put it off because forms, and dealing with forms and cleaning is the biggest time waste in history so having something reusable is more than brilliant.
Don't be an absolute prat like I was for ages and have tons of code with a load of if statements checking if variables are set, put the variable list in an array. E.g.
$adsCreateFields = array('bannerimage', 'buttonimage', 'urllink', 'companyname', 'smalldesc', 'largedesc', 'howearn',
'smalldescfreebie', 'largedescfreebie', 'howearnfreebie', 'payment', 'network', 'status', 'freebieok', 'cashbackok');
function &ads_get_input($fields)
{
$rh = &new RequestHandler; <-- this has already stripped all request data if magic quotes on
// keep only the fields required
foreach ($fields as $key)
{
if (isset($rh->data[$key]))
$data[$key] = $rh->data[$key];
else
$data[$key] = '';
}
// replace the data array and trim and specialchars the lot in one go ready to go back into forms if there was an error in validation
$rh->data = &$data;
$rh->trim();
$rh->specialchars();
return $data;
}
My form class also has loads of validation guff inside, you can specify by passing in information on what must be supplied, what type it must be, and see if it's within bounds.
But the biggest rule... make sure ints are ints, and cast them with $page=(int)$page