CodeIgniter Forums
how to read response values from the form - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to read response values from the form (/showthread.php?tid=26094)



how to read response values from the form - El Forum - 01-05-2010

[eluser]Thea_G[/eluser]
Can someone direct me to an example of how to read the form values on the view page from the controller function where it was submitted?

I used firebug and I can see the values got passed in the http response but how do I stuff them into the $data array I'm trying to build ( so I can update my database).

I want to do something like this:


Code:
$data = array(
                           'firstname' => post('firstname'),
                           'lastname' =>  post('lastname'),
                           'email' =>  post('email')
                    );

$this->db->insert('users', $data);



how to read response values from the form - El Forum - 01-05-2010

[eluser]runrun[/eluser]
If you want to see the submitted value in the view you can do this in your controller

Code:
$data['inputs'] = array(
                           'firstname' => post('firstname'),
                           'lastname' =>  post('lastname'),
                           'email' =>  post('email')
                    );


$this->load->view('your_view_file',$data );

And in the view

you echo $input you will see the array.


how to read response values from the form - El Forum - 01-06-2010

[eluser]Thea_G[/eluser]
Thanks for the reply. I'm new to codeigniter and not quite sure where to find a good example of inserting and updating the database with data entered from a web form.

In my example above, the problem is with the $data variable, it isn't getting the values assigned from my post('fieldname') command. This is just a command I made up since I don't know the way I'm supposed to do it in codeigniter. I'm not sure how to pull the values out of the form so I can add them to my database.

thanks!


how to read response values from the form - El Forum - 01-06-2010

[eluser]n0xie[/eluser]
Code:
$data = array(
                           'firstname' => $this->input->post('firstname'),
                           'lastname'  => $this->input->post('lastname'),
                           'email'     => $this->input->post('email')
                    );

$this->db->insert('users', $data);



how to read response values from the form - El Forum - 01-06-2010

[eluser]runrun[/eluser]
just show your VIEW and your CONTROLLER code, we will be able to you where the problem is.


how to read response values from the form - El Forum - 01-06-2010

[eluser]Thea_G[/eluser]
$this->input->post('field');


worked perfectly! ! !

thank you


how to read response values from the form - El Forum - 01-06-2010

[eluser]runrun[/eluser]
oh i gave the wrong syntax. I forget to put $this->input->. Sorry, but i'm glad you got it.