Form not submitting data |
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
should your inputs and textarea's not have name's?
Code: <input type="text" name="fname">
"Make it idiot proof and someone will make a better idiot."
@majortom84,
Interesting, you are using... if( empty( $this->input->post() ) ) instead of... if ($this->form_validation->run() == FALSE) Any reason why?
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) (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()
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')) {
(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.
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. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |