Page 1 of 1

Been searching all day could someone help with forms plz?

Posted: Fri Aug 18, 2006 6:56 pm
by sansoo
Ok ive been trying to find the best solution for passing variables from one page to another all day.

Ive seen the use of hidden fields being implented with a while loop in php. I have gotten this to work but it seems like a lot of extra code being generated.

Is this the best way to do it? Or can i use a $_REQUEST to get them?


The reason i ask is because i have a couple large forms that need to be validated. The form uses the POST method and sends the variables to another page to be validated and displayed so the user can double-check if all is correct.

Then i need the variables to be passed to a terms/conditions page and held there kinda in limbo until the agree box is checked and the account is created by posting them to a MySQL DB.

What is the best way to accomplish this?
Should i have the form post to itself for validation then onto to terms page so im only passing them to one additional page?

Or is there a way to post the variables to the DB after validation and then if the terms are agreed upon delete them back out?

Any suggestions would be greatly appreciated?

Posted: Fri Aug 18, 2006 6:59 pm
by feyd
This is asked very often here. The solution: use sessions.

Posted: Fri Aug 18, 2006 7:01 pm
by s.dot
They will all be accessable via the $_POST array, which is how you should access them. Using $_REQUEST or extract or a foreach($_POST AS $k=>$v){} yeilds security issues.

You can design the form multi-page or single page, but you don't need to store them in a database. Sessions would suffice for storage in this situation.

Posted: Fri Aug 18, 2006 7:26 pm
by sansoo
I guess i just didnt understand what a session was used for and how it kept track of variables. Anything to do with arrays and sessions is still confusing the hell out of me right now.

So once a session is started all variables entered will be kept until it is ended?

Posted: Fri Aug 18, 2006 10:31 pm
by feyd
Provided you store them into the session, generally speaking, yes they will be available until you destroy them or they have aged beyond their lifespan.

Posted: Fri Aug 18, 2006 11:43 pm
by RobertGonzalez