Welcome Guest, Not a member yet? Register   Sign In
Best way to handle different stages in a form
#1

[eluser]september28[/eluser]
Hi there,

Just wanted to see what people do to handle different stages in a form process. For instance, when a user orders something they might first select the product, then they go to the invoice address, press submit and then a shipping form appears, the press select and based on the shipping address they have given, the price of postage and packaging appears, they press ok, then the credit card details then they press ok and finally the order is complete.

Just wanted to know how people deal with those different stages in a controller.

Do you save a flash_data session variable called stage and give it values 1,2,3,4,5 for each other the stages and then use if statements to discover which stage the user is at? e.g.

Code:
function test() {
  if ($flash_data_var == 1) {
      //display first stage of form process
  }
  if ($flash_data_var == 2) {
      //process some first stage info and then show second stage of form process
  }
  etc...
}

Can anyone shed some light?

Cheers,

Dan
#2

[eluser]TheFuzzy0ne[/eluser]
Is there any reason why you can't have this form represented by an entire controller? Each page can be a method.
#3

[eluser]phused[/eluser]
An alternative solution would be to store all the form data using cookies/sessions. Once the data is validated use set_userdata() to store the data in a session and userdata() to retrieve the values on the final step.

Bare in mind that cookies can only hold up to 4KB of data.
#4

[eluser]TheFuzzy0ne[/eluser]
[quote author="Phused" date="1241407209"]Bare in mind that cookies can only hold up to 4KB of data.[/quote]

That is unless you use the database for sessions, in which case I think that limit goes up to 65KB.




Theme © iAndrew 2016 - Forum software by © MyBB