Been searching all day could someone help with forms plz?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sansoo
Forum Commoner
Posts: 32
Joined: Mon Aug 14, 2006 5:33 pm
Location: Smallville

Been searching all day could someone help with forms plz?

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This is asked very often here. The solution: use sessions.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
sansoo
Forum Commoner
Posts: 32
Joined: Mon Aug 14, 2006 5:33 pm
Location: Smallville

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Post Reply