Hey there,
Maintaining state in a web application is always a difficult thing.. fortunatly, you
use PHP, which makes it a bit easier. However, if you do not want anything written to
the server or to the user's drive you are out of luck, simply because at very least
you will need to have the user download your HTML which will be written to the hard
drive for caching. There are a few ways of doing making this work:
1) Store the form values from the previous form stored in hidden form fields on each
page of the form, such as the fields the user filled out on form1 will be stored as
hidden form fields on form2, the fields from form1 and form2 will be stored in hidden
fields on form3, etc.. This is not the cleanest way, but as far as crossplatforming
goes, it's one of the best.
2) Use a cookie to store the form fields. YUCK! Cookies have many good
applications, but they are usually disabled on the user's browser as they have been
miss used in the past. of course, this goes against your rule of keeping things from
being written on the user's harddrive.
3) Finally, you could use sessions. The cleanest way i would think to pass variables
from one form to another is to create an object in PHP that contains the fields in the
form as variables. Pass that object from form to form, adding the information the
application recieves from the user into the object at each form submit. That way, all
you have to do is to pass the sessionid from page to page. How do you do that you
ask? 2 ways: 1) you could save it in a cookie (this is the default way of passing
sessionids in PHP), 2) OR you can use a really cool thing PHP does and turn
URL-rewriting on in the php.ini file. This will automatically rewrite all the urls
you have on your page to append the ?SESSIONID=<id> at the end and include the
sessionid as a hidden form field on all your pages. Cool, huh? yeah.. PHP kicks ass.
=)
If you need more help on how to do this, don't hesitate to ask.
good luck!
-Chris
-----Original Message-----
From: Beauford.2002 [mailto:[EMAIL PROTECTED]]
Sent: Sat 2/15/2003 10:02 AM
To: PHP General
Cc:
Subject: [PHP] Forms Question
Hi,
Im trying to figure out the best way to do the following. I need to have a
series of forms that when the user finishes the first part of the form he is
sent to another page where a second form is filled out, and then a third.
Making the forms etc. is no problem, what I'm not sure of is how to keep the
data from all forms so it can be displayed at the end. I don't want to have
anything written to the users drive, or to the server - so this information
would have to be kept in memory. Would an array work in this situation?
Any ideas are appreciated.
TIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php