Welcome Guest, Not a member yet? Register   Sign In
How to create IF->ELSE with input->post() with checkbox array?
#2

(This post was last modified: 09-23-2016, 05:08 AM by Wouter60.)

PHP Code:
if($item){ //Run only when submit the form
 
 if ($item == NULL) { 

This will never work. If you haven't selected any checkbox, $item will be empty, so the line with "if ($item == NULL) {" will not be executed.
I assume that your form has a submit button, probably with the name "submit".
PHP Code:
$submit $this->input->post('submit');
if (
$submit) {
 
 $items $this->input->post('service');
 
 if (! empty($items)) {
 
   foreach($items as $item) {
 
       //process the checkboxes that where checked
 
   }
 
 }
 
 else {
 
     // redirect
 
 }


Reply


Messages In This Thread
RE: How to create IF->ELSE with input->post() with checkbox array? - by Wouter60 - 09-23-2016, 03:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB