[eluser]Flying Fish[/eluser]
There may be a better way of going about this. I'm pushing the limits on my php skills here.
So here's the scenario, a user submits a valid form, then they review the data they submitted and can either 1. go back and make changes, or 2. confirm their data is correct
My questions are
1. I have all the users POST data for the confirmation page, but how do I repopulate the form if they choose to go back?
2. If they confirm their data, how do I write it all into the database?
Here is the controller.
Code:
function add_info()
{
// Check if the form has been submitted and passed validation
// if it has show confirmation page
if ($this->input->post('submit') && $this->form_validation->run() === TRUE)
{
$data['title'] = "Review Your Order";
$data['heading'] = "Let's Review Your Order";
$this->load->view('order_review', $data);
} else if ($this->input->post('submit') && $this->form_validation->run() === FALSE)
{
// The form has been submitted and there are errors
$data['title'] = "Oops! Let's double check that form.";
$data['heading'] = "Oops! Let's double check that form.";
} else
{
// The form has never been submitted, show the form
$data['title'] = "Add Your Information";
$data['heading'] = "Add Your Information";
}
// Load this view by default
$this->load->view('order_add_info', $data);
}
Here's the view file for 'order_review'
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?=$title?></title>
</head>
<body>
<h1><?=$heading?></h1>
<p>Last but not least, please double check your info for accuracy.</p>
<h2>Important</h2>
<p>Please double check your info for mistakes! This will be exactly what is printed on your item.<p>
<p>We can't be responsible for misspellings or typos.</p>
<div id="review">
<p>I want to order <?=$_POST['order_quantity'];?> items with the following info:</p>
<h2>When</h2>
<div><h3>Dates</h3><?=$_POST['when_dates'];?></div>
<div><h3>Times</h3><?=$_POST['when_times'];?></div>
<div><h3>Note</h3><?=$_POST['when_registration'];?></div>
<div><h3>Extras</h3><?=$_POST['when_extra'];?></div>
<h2>Who</h2>
<div><h3>Ages</h3><?=$_POST['who_ages'];?></div>
<div><h3>Extras</h3><?=$_POST['who_extra'];?></div>
<h2>Where</h2>
<div><h3>Church Name</h3><?=$_POST['where_name'];?></div>
<div><h3>Address</h3><?=$_POST['where_street'];?></div>
<div><h3>City</h3><?=$_POST['where_city'];?></div>
<div><h3>State</h3><?=$_POST['where_state'];?></div>
<div><h3>Zip</h3><?=$_POST['where_zip'];?></div>
<div><h3>Phone(s)</h3><?=$_POST['where_phone'];?></div>
<div><h3>Website</h3><?=$_POST['where_web'];?></div>
<div><h3>Extras</h3><?=$_POST['where_extra'];?></div>
<div><?=anchor('/order/add_info/'.'enter-var-here', 'I need to make some changes!');?></div>
<div><?=anchor('/order/submit/', 'Everything looks ok.');?></div>
</div>
</body>
</html>
I'm attaching the view 'order_add_info' as a zip file
Let me kno if I can clarify any of this. Thanks!