Welcome Guest, Not a member yet? Register   Sign In
print all data that has been posted in form, into confirmation view

[eluser]Brad K Morse[/eluser]
I am creating a confirmation view, and I need to grab all the data that was posted from a post and pass it into that view.

There must be a simple way of doing this...

something like...

$data[] = $this->input->post('name_of_form');
$this->load->view('confirmation-view', $data);

Then within the view, I can print it out like:




Trying to avoid:

$data['email'] = $this->input->post('email'); $data['first_name'] = $this->input->post('first_name'); ...

or if there is a better way of creating confirmation before db insertion, I am all ears.

Thank you.



$data['steps'] = $this->input->post('step_id[]');
$data['message'] = $this->input->post('message');
$data['department_id'] = $this->input->post('department_id');

Problem now is storing the step_id[] appropriately, it does not display in the confirmation view. step_id[] is a series of checkboxes, that have the same name (step_id[]), I do not know how to store that array of values into the $data['steps'] array, to be passed into the confirmation view.




&lt;?php print_r($steps); ?&gt;

Resolved; Had to take the [] out of step_id in the post, so now it works with $data['steps'] = $this->input->post('step_id');

If there is a better way to do this, I am still all ears. Smile

[eluser]Line 210[/eluser]
You could try this:

public function method_name()
    foreach($_POST as $key=>$value)
        $data[$key] = $this->input->post($key);

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

[eluser]Line 210[/eluser]
For the checkboxes what I've done is given each checkbox a unique name and loop thru it like any other form element. Do they have to all be named the same?

[eluser]Brad K Morse[/eluser]

[eluser]Brad K Morse[/eluser]
Probably not the right way to accomplish this??


$steps = $this->input->post('step_id');

foreach($steps as $step_id) {
    $data['stepTitles'] .= $this->add_model->getStepTitles($step_id);

This is not working.

It's hard to know for sure without seeing all of your code, but this may work:

$data['stepTitles'][$step_id] = $this->add_model->getStepTitles($step_id);

[eluser]Brad K Morse[/eluser]
You are good, real good. Antoine Dodson good.

Theme © iAndrew 2016 - Forum software by © MyBB