psuplat Posted July 8, 2010 Share Posted July 8, 2010 Hi everyone, I'm facing a problem when submiting checkboxes values to db. On form a have 3 checkoxes titled Visual, Functional, Data. They will relate to the db table fields: visual, functional, data In db those fields are set to YES/NO values. When the user ticks the checkbox, it's value is being posted ($_POST['f_visual']="YES"). But when the checkbox has not been ticked, it is not being posted at all. Now, I know that this is correct from HTML point of view, as element not checked doesn't need posting, but how can I make the unchecked textbox post "NO" value. I've tried many different ways to go around it: for one - setting default value of $_POST['f_visual'] as "NO" on first page at the begining of the sesion, other approach - on page that controls post actions I set variable $t_visual to "NO", then using if isset I checked if $_POST['f_visual'] existed. if so I did $t_visual = $_POST['f_visual']., plus many other approaches. Nothing works, any ideas how to do it? Link to comment https://forums.phpfreaks.com/topic/207130-checkbox-values/ Share on other sites More sharing options...
Barand Posted July 8, 2010 Share Posted July 8, 2010 $f_visual = isset($_POST['f_visual']) ? 'YES' : 'NO'; Link to comment https://forums.phpfreaks.com/topic/207130-checkbox-values/#findComment-1082989 Share on other sites More sharing options...
psuplat Posted July 8, 2010 Author Share Posted July 8, 2010 probably a silly/stupid question but where you put this in? on page with actual form, or rather on the page that handles the submissions (I'm betting the later) Link to comment https://forums.phpfreaks.com/topic/207130-checkbox-values/#findComment-1082991 Share on other sites More sharing options...
Barand Posted July 9, 2010 Share Posted July 9, 2010 On the page that is processing the POSTed data (which may be the same as the form, or not) Link to comment https://forums.phpfreaks.com/topic/207130-checkbox-values/#findComment-1083462 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.