Re: Another form handling posting question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:36 PM -0700 12/5/07, Mike Smith wrote:
I am trying to recursively send data to the same form.

-snip-

What is the best practice for doing this?


I don't know what the "best" practice is, but this is the way I do it.

In the form I have a hidden field called step that controls flow via POST..

Based upon that value, I use a switch to direct the flow to different forms -- all the forms have the same submit button.

So, it looks like this (pseudo-code):

$step = isset($_POST['step']) ? $_POST['step'] : 1;

<form action=self method=post>

switch $step
  {
  case 1:
  // present the form for step 1
  <input hidden step=2>

  case 2:
  // present the form for step 2
  <input hidden step=3>

  case 3:
  // present the form for step 3
  }

<input type=submit name=submit type=submit>

That way, it's simple to recursively change a form to gather information.

If you want to keep/store data in each gather, then either save it to a dB or do sessions.

It works for me.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux