Best way to pass variables ?

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
SBro
Forum Commoner
Posts: 98
Joined: Tue Sep 30, 2003 10:06 pm

Best way to pass variables ?

Post by SBro »

Hi, I was just wondering what the best method is to pass variables in php. I know how to pass variabes, but the problem is this; I have a number of form elements (around 20) that I am passing between a couple of pages and eventually using to structure an e-mail. The concern I have is that by the end of passing all the variables I will have a stupidly long address with (20) "&var=$blah". I'm not sure whether this is particularly a problem, just wondering if there was a better or alternate way to do this.

If possible I don't want to use a database for this as there is no real need to keep the values from the form(s) after the end e-mail has been sent. I was also thinking of cookies, but not sure whether that would be a better method or not? thanks.

Steve.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]sessions[/php_man]
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

I agree sessions is the way to go.

NOTE: passing the parameters as POST rather than GET is more secure and does not increase the length of the address. GET also has a much smaller limit as to the amount of data you can pass. ('<form action="XXX" method="POST">')
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

again, the link to the session tutorial written by jason would be handy if there was such a link again

:evil: :roll: :wink:
Post Reply