jd2007 Posted July 15, 2007 Share Posted July 15, 2007 how do i check if a checkbox is checked or not in php ?...pls help Link to comment https://forums.phpfreaks.com/topic/60072-how-do-i-check-if-a-checkbox-is-checked-or-not-in-php/ Share on other sites More sharing options...
wildteen88 Posted July 15, 2007 Share Posted July 15, 2007 Example: <?php if(isset($_POST['submit'])) { if(isset($_POST['chk_box'][0]) && $_POST['chk_box'][0] == 'somevalue') { echo 'checkbox1 - Selected'; } else { echo 'checkbox1 - Not Selected'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Checkbox1: <input type="checkbox" name="chk_box[]" value="somevalue" /><br /> Checkbox2: <input type="checkbox" name="chk_box[]" value="anothervalue" /><br /> <input type="submit" name="submit" value="Submit Checkboxes" /> </form> Link to comment https://forums.phpfreaks.com/topic/60072-how-do-i-check-if-a-checkbox-is-checked-or-not-in-php/#findComment-298788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.