only1perky Posted February 5, 2009 Share Posted February 5, 2009 Hi guys, I'm trying to update my database with a certain number of checkboxes. At the moment I have this in my form: <input name="mailinglist" type="checkbox" id="mailinglist" value="1" <? if($row_rsdetails['mailinglist'] == 1){ ?> checked="checked" <? } ?>/> This works and updates the database with the value 1 when checked. What I can't figure out is how to update the database with 0 if the box is unchecked. I'm sure this is glaringly obvious but I'm stumped. Cheers. Link to comment https://forums.phpfreaks.com/topic/143929-update-database-by-checkboxes/ Share on other sites More sharing options...
s0c0 Posted February 5, 2009 Share Posted February 5, 2009 If the POST variable is not set, then set it to 0 as the box was not checked. This should do it. if(!isset($_POST['mailinglist'])){ $_POST['mailinglist']=0; } Link to comment https://forums.phpfreaks.com/topic/143929-update-database-by-checkboxes/#findComment-755268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.