I have this checkbox:
<label>Maintenance Mode: <small>Tick to enable/disable.</small></label>
<input type="checkbox" name="maintenance" value="1" <?php echo $maintenance; ?> >
I get the data from my database. So, if maintenance is enabled in my database, then the checkbox will be checked on. That happens like this:
if($sdata['maintenance']==1):
$maintenance="checked='checked'";
else:
$maintenance="";
endif;
The problem is, whenever I want to disable maintenance, it doesn't update the database. It will still be set to "1".
This is how I post it:
$maintenance = inputFilter($_POST['maintenance']);
My database table have two columns:
setting_name and setting_value. In this case, it would be:
maintenance and 1
I update it like this:
foreach($_POST as $key => $value)
{
$value = inputFilter($value);
mysql_query("UPDATE settings SET setting_value='$value' where setting_name='$key' limit 1")
or die(mysql_error());
}
Whenever I uncheck the checkbox, and save the settings, nothing happens. I even tried to echp $maintenance from the post, and when it's unchecked, the value is 0.
Anyone have any idea what is causing this?