ka3pmw Posted November 8, 2012 Share Posted November 8, 2012 I am having a problem with sending the value from a checkbox to a mysql table. If the box is not checked I want to send a 0 if it is I want to send a 1, I also eant to treat the column as an int. How can I do this? My input field looks like this: <td align="left" valign="top">Allow Duplicates</td> <td colspan="2" align="left" valign="top"><input type="checkbox" name="allow_dupes" id="allow_dupes" value="0" /></td> mu php code is like this: extract($_POST); $sql="INSERT INTO `mylog` (`callclub`, `arrlsect`, `ituzone`, `ituregion`, `grid`, `utcoffset`, `contest`, `logname`, `crossmode`, `xmitters`, `numoperators`, `numstations`,`time_date`, `assisted`, `power`, `overlay`, `allowdupes`, `rrst`, `rdatetime`, `rcallsign`,`rsection`,`rzone`,`rband`,`rmode`,`rfrequ`,`rregion`,`rgridlog`, `srst`, `sdatetime`, `scallsign`,`ssection`,`szone`,`sband`,`smode`,`sfrequ`,`sregion`,`sgridlog`,`name`, `address`, `city`, `state`, `zip`, `country`,`soap1`, `soap2`) VALUES('$call_club','$arrl_section','$itu_zone','$itu_region','$grid','$utc_offset','$contest_name','$log_name','$cross_mode','$numofxmit','$numofops','$numofstations','$timedate','$assistedyn','$power','$overlay_name','$allow_dupes','$rlog_rst','$rlog_date','$rlog_callsign','$rlog_section','$rlog_zone','$rlog_band','$rlog_mode','$rlog_frequency','$rlog_region','$rlog_grid','$slog_rst','$slog_date','$slog_callsign','$slog_section','$slog_zone','$slog_band','$slog_mode','$slog_frequency','$slog_region','$slog_grid','$contact_name','$contact_address','$contact_city','$contact_state','$contact_zip','$contact_country','$soap1','$soap2')"; if (!mysql_query($sql,$con)) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/270466-checkboxes/ Share on other sites More sharing options...
MDCode Posted November 8, 2012 Share Posted November 8, 2012 <?php if($_POST['allow_dupes'] == "0") { $allow_dupes = 1; } else { $allow_dupes = 0; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/270466-checkboxes/#findComment-1391109 Share on other sites More sharing options...
akphidelt2007 Posted November 8, 2012 Share Posted November 8, 2012 It will not show up if it is not clicked so you can easily do... $allow_dupes = isset($_POST['allow_dupes']) ? 1 : 0; Quote Link to comment https://forums.phpfreaks.com/topic/270466-checkboxes/#findComment-1391115 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.