Welcome Guest, Not a member yet? Register   Sign In
need helping making POST data last for several page refreshes, so user can confirm data
#1

[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">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

    <h1>&lt;?=$heading?&gt;</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 &lt;?=$_POST['order_quantity'];?&gt; items with the following info:</p>
    <h2>When</h2>
    <div><h3>Dates</h3>&lt;?=$_POST['when_dates'];?&gt;</div>
    <div><h3>Times</h3>&lt;?=$_POST['when_times'];?&gt;</div>
    <div><h3>Note</h3>&lt;?=$_POST['when_registration'];?&gt;</div>
    <div><h3>Extras</h3>&lt;?=$_POST['when_extra'];?&gt;</div>
    <h2>Who</h2>
    <div><h3>Ages</h3>&lt;?=$_POST['who_ages'];?&gt;</div>
    <div><h3>Extras</h3>&lt;?=$_POST['who_extra'];?&gt;</div>
    <h2>Where</h2>
    <div><h3>Church Name</h3>&lt;?=$_POST['where_name'];?&gt;</div>
    <div><h3>Address</h3>&lt;?=$_POST['where_street'];?&gt;</div>
    <div><h3>City</h3>&lt;?=$_POST['where_city'];?&gt;</div>
    <div><h3>State</h3>&lt;?=$_POST['where_state'];?&gt;</div>
    <div><h3>Zip</h3>&lt;?=$_POST['where_zip'];?&gt;</div>
    <div><h3>Phone(s)</h3>&lt;?=$_POST['where_phone'];?&gt;</div>
    <div><h3>Website</h3>&lt;?=$_POST['where_web'];?&gt;</div>
    <div><h3>Extras</h3>&lt;?=$_POST['where_extra'];?&gt;</div>
    <div>&lt;?=anchor('/order/add_info/'.'enter-var-here', 'I need to make some changes!');?&gt;</div>
    <div>&lt;?=anchor('/order/submit/', 'Everything looks ok.');?&gt;</div>
    </div>

&lt;/body&gt;
&lt;/html&gt;


I'm attaching the view 'order_add_info' as a zip file

Let me kno if I can clarify any of this. Thanks!


Messages In This Thread
need helping making POST data last for several page refreshes, so user can confirm data - by El Forum - 03-14-2009, 12:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB