phppup Posted December 19, 2018 Share Posted December 19, 2018 I am using this code to evaluate whether checkboxes within a group have been selected: function IsChecked($chkname,$value) { if(!empty($_POST[$chkname])) { foreach($_POST[$chkname] as $chkval) { if($chkval == $value) { return true; } } } return false; } Now, I've decided that I want to add a message upon finding NO SELECTED checkbox items, but it is not functioning as desired. if(empty($_POST[$chkname])) { echo("You didn't select any checkboxes."); } How can I get this or something similar to trigger? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 19, 2018 Share Posted December 19, 2018 Only checkboxes that have been checked are posted. If it's there it's checked. If it's not there it ain't. Quote Link to comment Share on other sites More sharing options...
phppup Posted December 19, 2018 Author Share Posted December 19, 2018 That makes an incredible amount of sense. Will something like if($value=null) or value==zero work for me? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 19, 2018 Share Posted December 19, 2018 To check if it's there if ( isset($_POST['checkname']) ) { // it's there - process it } 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.