PDA

View Full Version : Using PHP to check if a ChekBox is Checked


pyro.699
10-25-2005, 10:27 PM
if (isset($_POST['rpg_name_int']))
{
$db->query_write(
"UPDATE ". TABLE_PREFIX ."thread
SET rpg_name_int = '1',
WHERE threadid = '" . $vbulletin->threadinfo['threadid'] . "'
);
}

This is used in a plugin

Hook Location: newthread_post_complete


nothing really happens. no errors, i check my db, i took a sc of what i want it to look like


www.frozencreations.net/stuff/stuff.gif


when it posts i want it to set those values to 1

Ty

~Cody

deathemperor
10-26-2005, 02:46 AM
if a checkbox is checked, it will return true or 1, otherwise false or 0.

So I think you should try removing isset()
and in the condition I suggest you use print_no_permission(); if the conditions are met.

Guest190829
10-26-2005, 05:26 AM
if ($_POST['rpg_name_int'] == '1')
{
$db->query_write("UPDATE ". TABLE_PREFIX ."thread
SET rpg_name_int = '1'
WHERE threadid = '" . $vbulletin->threadinfo['threadid'] ."'
");
}
else
{
// do check or something else here
}


Try the above to see if it works. Also make sure you sanitize this $_POST variable. :)

pyro.699
10-26-2005, 09:22 AM
what? sorry, i dident get that?

deathemperor
10-26-2005, 04:25 PM
try


if ($_POST['rpg_name_int'])
{
$db->query_write(
"UPDATE ". TABLE_PREFIX ."thread
SET rpg_name_int = '1',
WHERE threadid = '" . $vbulletin->threadinfo['threadid'] . ""
);
}