![]() |
Form not submitting data - 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: Form not submitting data (/showthread.php?tid=71619) |
Form not submitting data - majortom84 - 09-05-2018 I have this working in another Controller so I am not sure why it is not working in this one. Controller: Code: public function contact(){ View: Code: <div class="container-contact"> Testing in postman works, just not seeing anything in CI on backend RE: Form not submitting data - kierownik - 09-05-2018 should your inputs and textarea's not have name's? Code: <input type="text" name="fname"> RE: Form not submitting data - php_rocs - 09-05-2018 @majortom84, Interesting, you are using... if( empty( $this->input->post() ) ) instead of... if ($this->form_validation->run() == FALSE) Any reason why? RE: Form not submitting data - neuron - 09-05-2018 as I remember empty() function does not accept return values; so U can't run if(empty($this->input->post())) instead I just use if($this->input->post() == null) RE: Form not submitting data - neuron - 09-05-2018 (09-05-2018, 04:23 PM)php_rocs Wrote: @majortom84, assume that u need to show alert when validation failed and you submit your form to the same url where you view the form (which is common way in CI): PHP Code: public function foo() RE: Form not submitting data - Wouter60 - 09-06-2018 Like kierownik said: $_POST (or $this->input->post()) will only have values if the inputs have names. Best practice is to give the submit button a name also: PHP Code: <button type="submit" name="submit" class="hollow button submit">Submit</button> Then, in your controller: PHP Code: if ($this->input->post('submit')) { RE: Form not submitting data - majortom84 - 09-06-2018 (09-05-2018, 04:22 PM)kierownik Wrote: should your inputs and textarea's not have name's? This was it, found it about 10 min after I posted this. Would have added to post but my son needed my attention. RE: Form not submitting data - InsiteFX - 09-06-2018 Using JavaScript and with forms you should always give the input elements a name, if you use the class along with name give them both the same name. Will give you piece of mind. |