![]() |
Codeigniter multiple checkbox issue STRANGE! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Codeigniter multiple checkbox issue STRANGE! (/showthread.php?tid=64047) |
Codeigniter multiple checkbox issue STRANGE! - frobak - 01-06-2016 m using codeigniter and I have a very simple form, which has a few checkboxes: Code: <input type="checkbox" name="user_assign[]" value="' . $row->user_id . '"> Code: user_assign[]100002 Code: $user_assign = $this->input->post('user_assign'); Here is the controller: PHP Code: function update_course_assignment_org() { At the moment I am just trying to get the POST vars into the controller. Its just not working. I can echo/print the POST vars no problem. But I just cannot get the POST vars into the contoller with $this->input->post('user_assign') RE: Codeigniter multiple checkbox issue STRANGE! - Avenirer - 01-07-2016 maybe you should show us more code... RE: Codeigniter multiple checkbox issue STRANGE! - frobak - 01-07-2016 (01-07-2016, 03:38 AM)Avenirer Wrote: maybe you should show us more code... added controller RE: Codeigniter multiple checkbox issue STRANGE! - Avenirer - 01-07-2016 so... when you do a print_r($this->input->post('user_assign')); you get nothing? I am asking this because in the controller you can't seem to use that $user_assign you are talking about... RE: Codeigniter multiple checkbox issue STRANGE! - frobak - 01-07-2016 (01-07-2016, 04:05 AM)Avenirer Wrote: so... when you do a print_r($this->input->post('user_assign')); you get nothing? Thats right, its NULL, empty I've tried the following: Code: print_r($this->input->post('user_assign')) ; NULL Code: print_r( $this->input->post()); NULL Code: $user_assign = substr(implode(', ', $this->input->post('user_assign')), 0); NULL Code: foreach ($this->input->post('user_assign') as $key => $value) { NULL RE: Codeigniter multiple checkbox issue STRANGE! - Avenirer - 01-07-2016 This is rather impossible, unless there are no checkboxes selected (ticked). RE: Codeigniter multiple checkbox issue STRANGE! - frobak - 01-07-2016 (01-07-2016, 04:15 AM)Avenirer Wrote: This is rather impossible, unless there are no checkboxes selected (ticked). oh boy, don't I just know that. It makes absolutely no sense whatsoever. Code: print_r($_POST); above code give outputs: Code: Array ( [user_assign] => Array ( [0] => 100002 [1] => 100003 ) [course_name] => Slips & Trips ) and when i try this: Code: print_r($this->input->post('user_assign')); it outputs nothing. it empty? RE: Codeigniter multiple checkbox issue STRANGE! - frobak - 01-07-2016 I have this thread on SO been going for a while. Everybody seems to be completely stumped. I mean what the hell is going on? http://stackoverflow.com/questions/34643460/codeigniter-multiple-checkbox-issue RE: Codeigniter multiple checkbox issue STRANGE! - frobak - 01-07-2016 I managed to get the data i wanted by using: $assignmen = @$_POST['user_assign']; RE: Codeigniter multiple checkbox issue STRANGE! - Avenirer - 01-07-2016 Not a good idea, as $_POST has no validation, and @ won't show the eventual errors you may get... |