Jump to content

Forms Multiple Pages Dont Want To Submit Till Last Page


JustinK101

Recommended Posts

I have a sign up form, which has four pages, with each page having a form and fields. I want to pass each pages form data on to the next page until finally the fourth page is filled out, then at that pull all the form data from each page and store into a mysql database. How is this possible? What is the most elegant way of doing this?

Link to comment
Share on other sites

I always find it easiest to make sure all form data is passed as an array.

 

<input type="text" name="formData[name]">

 

Elegant is a matter of opinion. ;)

  • Dump each pages form data ($_GET[formData or $_POST[formData]) into a session and append to that session with each subsequent page, on the last page insert from the session.
  • Serialize each pages formdata and place that serialized string into a hidden field.  Append to the string on subsequent pages.  Unserialize on the final page and perform your operations.

 

 

Best, Nathan

 

Link to comment
Share on other sites

Seems like storing the $_POST of each page in a session is the best way? Does it make sense to do:

 

# Page 1

 

$_SESSION['page_1'] = serialize($_POST);

 

# Page 2

 

$_SESSION['page_2'] = serialize($_POST);

 

# Page 3

 

$_SESSION['page_3'] = serialize($_POST);

 

# Page 4

 

$page_1 = unserialize($_SESSION['page_1']);

$page_2 = unserialize($_SESSION['page_2']);

$page_3 = unserialize($_SESSION['page_3']);

Link to comment
Share on other sites

I think that makes fine sense.

 

As long as $_POST is only what you want.  Of course you can unset() anything out of $_POST before serializing.

 

Keep in mind these types of User Interfaces is what AJAX is all about.

 

Best, Nathan

Link to comment
Share on other sites

Serialization certainly isn't required.

 

But to keep some sanity, I would recommend building a multidimensional array.

 

// Assign Page 1
$_SESSION['page_1'] = $_POST;

// Assign Page 2
$_SESSION['page_2'] = $_POST;

// Assign Page 3
$_SESSION['page_3'] = $_POST;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.