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? 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. 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? 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 } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.