Welcome Guest, Not a member yet? Register   Sign In
How to show a preview / confirmation page before writing the form to the database
#12

[eluser]thbt[/eluser]
Here's how I ended up doing it.

Code:
if ( $this->form_validation->run() == FALSE || isset( $_POST['edit_listing'] ) )
{
    // show form
}
else
{
   // Data passed validation
   if ( !isset( $_POST["really_write_to_db"] ) )
   {
       // Show the preview
   }
   else
   {
       // write to DB
   }
}

So basically I have a preview page with a bunch of <INPUT TYPE="HIDDEN"...> tags to store the form data, plus a <INPUT TYPE="HIDDEN" NAME="really_write_to_db" VALUE=1> kind of thing to have the next submit really write to the database.

Nice thing about it is, the data gets validated every time it goes through this bit of code. Also, no need to write to the DB until the very end, which improves performance.

Hope this helps.


Messages In This Thread
How to show a preview / confirmation page before writing the form to the database - by El Forum - 02-19-2009, 10:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB