CodeIgniter Forums
print all data that has been posted in form, into confirmation view - 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: print all data that has been posted in form, into confirmation view (/showthread.php?tid=36487)



print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

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

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

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

Code:
<?=$first_name?>

<?=$last_name?>

<?=$email?>

Trying to avoid:

Code:
$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.

UPDATE:

Controller

Code:
$data['steps'] = $this->input->post('step_id[]');
$data['message'] = $this->input->post('message');
$data['department_id'] = $this->input->post('department_id');
$this->load->view('confirmation-view',$data);

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.

View

Code:
<h3>Department</h3>
<p>&lt;?=$department_id?&gt;</p>

<h3>Message</h3>
<pre>&lt;?=$message?&gt;</pre>

<h3>Steps</h3>
&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


print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

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

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

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



print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

[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?


print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

[eluser]Brad K Morse[/eluser]
Yes


print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

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

Controller:

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

foreach($steps as $step_id) {
    $this->load->model('add_model');
    $data['stepTitles'] .= $this->add_model->getStepTitles($step_id);
}
$this->load->view('confirmation-view',$data);

This is not working.


print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

[eluser]zac[/eluser]
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);


print all data that has been posted in form, into confirmation view - El Forum - 12-03-2010

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