Welcome Guest, Not a member yet? Register   Sign In
how to read response values from the form
#1

[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);
#2

[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.
#3

[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!
#4

[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);
#5

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

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


worked perfectly! ! !

thank you
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB