Hi guys.
I have a form that has several checkbox with the same "name" attribute. I'm trying to do a conditional to know if any checkbox is checked or not, but I can not make it work. See how it is:
PHP Code:
// View (have foreach checkboxes with the name 'service[]', no other input/select/etc )
<input type = "checkbox" name = "service[]" value = "$numeric_id">
// Controller
$item = $this->input->post ('service', true);
if($item){ //Run only when submit the form
if ($item == NULL) {
// function if no checkbox is checked
// return to the same page with redirect(current_url());
}else{
// function if at least one checkbox was marked
// return to the same page with redirect(current_url());
}
}else{
//show the view with the checkboxes and submit form button
}
The problem is that when i don't select any checkbox the input->post("service") is not NULL, not as empty or equals "" (empty).
PHP Code:
if($item==NULL) not work
if($item==FALSE) not work
if($item=='') or if($item==' ') not work
if(empty($item)) not work
if(!isset($item)) not work
if(!is_array($item)) or (is_array($item)) not work
foreach($item as $key) or foreach($item as $key => $value) not work
Any idea what's wrong?