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 Quote Link to comment 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> Quote Link to comment 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.