Iain M
08-20-2011, 12:33 PM
Hi,
I'm having problems validating radio options from a form, before entering into the database.
Because the names of the radio options change depending on the row id.
I put my validation into a for loop, but it didn't work - nothing was posted from the form.
for($i=$oldestID['id'];$i<=$newestID['id'];$i++)
{
// Clean parameters
$vbulletin->input->clean_array_gpc('p', array(
'gender_$i' => TYPE_BOOL,
'free_$i' => TYPE_BOOL,
'active_$i' => TYPE_BOOL,
));
// Easy names
$gender = $vbulletin->GPC['gender_$i'];
$free = $vbulletin->GPC['free_$i'];
$active = $vbulletin->GPC['active_$i'];
// Do stuff
}
The names of the fields are:
gender_{vb:raw id}
free_{vb:raw id}
active_{vb:raw id}
id changes for each row pulled from the database, so we'll have
HEADER
Row 1: gender_1 | free_1 | active_1
Row 2: gender_2 | free_2 | active_2
Row 10: gender_10 | free_10 | active_10
Could someone point me in the right direction?
If I use
$gender = $_POST["gender_$i"];
$free = $_POST["free_$i"];
$active = $_POST["active_$i"];
in my for loop, it works fine, but I'd rather validate the entries.
Thanks in advance for your help.
Iain
I'm having problems validating radio options from a form, before entering into the database.
Because the names of the radio options change depending on the row id.
I put my validation into a for loop, but it didn't work - nothing was posted from the form.
for($i=$oldestID['id'];$i<=$newestID['id'];$i++)
{
// Clean parameters
$vbulletin->input->clean_array_gpc('p', array(
'gender_$i' => TYPE_BOOL,
'free_$i' => TYPE_BOOL,
'active_$i' => TYPE_BOOL,
));
// Easy names
$gender = $vbulletin->GPC['gender_$i'];
$free = $vbulletin->GPC['free_$i'];
$active = $vbulletin->GPC['active_$i'];
// Do stuff
}
The names of the fields are:
gender_{vb:raw id}
free_{vb:raw id}
active_{vb:raw id}
id changes for each row pulled from the database, so we'll have
HEADER
Row 1: gender_1 | free_1 | active_1
Row 2: gender_2 | free_2 | active_2
Row 10: gender_10 | free_10 | active_10
Could someone point me in the right direction?
If I use
$gender = $_POST["gender_$i"];
$free = $_POST["free_$i"];
$active = $_POST["active_$i"];
in my for loop, it works fine, but I'd rather validate the entries.
Thanks in advance for your help.
Iain