PDA

View Full Version : Sanitize $_POST array


ptmuldoon
11-25-2008, 04:30 PM
I have a form that creates an array of variables such as
<input type="hidden" name="id[]" value="'.$ID.'" />

When processing the data, what is the proper way to sanitize the input and keep the input as a array so that it can be used in a loop?

$ids = $_POST['id']; //Need to Sanitize

//$vbulletin->input->clean_array_gpc('p', $ids); This is incorrect?

foreach($ids as $id){
$value = $_POST['active'][$id]; //Need to Sanitize
//Do More Processing
}

Dismounted
11-26-2008, 03:34 AM
$vbulletin->input->clean_array_gpc('p', array(
'id' => TYPE_ARRAY_UINT
));

foreach ($vbulletin->GPC['id'] AS $id)
{
echo $id;
}

Antivirus
11-26-2008, 02:32 PM
there's extensive documentation in the vbulletin user manual about using GPC...
http://www.vbulletin.com/docs/html/main/codestandards_gpc

and also a very handy article on the matter as well...
https://vborg.vbsupport.ru/showthread.php?t=119372