batecobre — 2011-09-05T21:07:46-04:00 — #1
Hi everyone! First post. Absolute beginner. Have most Sitepoint books.
I'm still not clear on what the best practices is on transferring data from page to page to page. I have a simple form with Name Title1 Title2..., Phone 1, Phone 2,... Email, etc., about 12 variables in all. As the user progresses from page to page, I find myself sending data by using:
header('Location: bctemplstandardproof.php?Name='.$Name.'?Title1='.$Title1.'?Title2='.$Title2.'?Title3='.$Title3.'?Title4='.$Title4.'?Email='.$Email.'?Phone1='.$Phone1.'?Phone2='.$Phone2.'?Phone3='.$Phone3.'?Phone4='.$Phone4.'?MailStop='.$Mailstop.'?po='.$po); or
<a href="bctemplstandard.php?po=<?php echo $po;?>"><img src="images/MoffittStandardExampleTitleBC.png"</a>
I'm not sure this is best practice. COOKIES and SESSIONS may be too advanced for me, and may be overkill. Any thoughts? Thanks in advance...
batecobre — 2011-09-06T20:25:54-04:00 — #2
Thank you so much! I really messed that up! & not ?.
I'll be switching to sessions, thanks!
system — 2011-09-05T22:24:16-04:00 — #3
I agree with felgall.
But if you want to use a query string like you have, a ? denotes the beginning of the query string in the url and subsequent name/value pairs are separated by an & and not a ?
felgall — 2011-09-05T22:15:52-04:00 — #4
A session would probably be the simplest way - far simpler than what you are currently using.
You simply need a session_start at the top of the PHP and then assign the fields into the $SESSION array and read them back from there in the following page instead of from the $_GET array.