By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

Carrying PHP Variables From Web Page To Web Page

P: n/a
I was reading about PHP variable scoping - it doesn't seem to support
carrying any variables from one web page to another - how is this
usually done? I have a lot of php variables created on my home page
that I need to make use of on other web pages - how can I do that?

Thanks...

Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> 3 choices
1) use sessions to hold the variables between pages
2) use hidden form fields and submit buttons (not secure)
3) use a database to hold the values and embed the key in your urls (e.g.
href='somepage.php?id=34')


.... of which sessions (option 1) is the best option, since that effectively
stores the values on the server as in option 3, but can pass the 'key' from
option 3 either as a cookie, form fields as in option 2 or as part of the
link, again from option 3.

David
Jul 16 '05 #2

P: n/a
Wm
Is it possible to do something like this:

Form on page1: POST to page2
Page2: extract($_POST)
hyperlink to Page3: <A HREF="page3.php?data=_POST">continue</A>

(I know it won't work as written, but is something similar possible?)

Wm
"David Walker" <wb*********@hotmail.com> wrote in message
news:bg**********@wisteria.csv.warwick.ac.uk...
3 choices
1) use sessions to hold the variables between pages
2) use hidden form fields and submit buttons (not secure)
3) use a database to hold the values and embed the key in your urls (e.g. href='somepage.php?id=34')
... of which sessions (option 1) is the best option, since that

effectively stores the values on the server as in option 3, but can pass the 'key' from option 3 either as a cookie, form fields as in option 2 or as part of the
link, again from option 3.

David

Jul 16 '05 #3

P: n/a
> Form on page1: POST to page2
Page2: extract($_POST)
hyperlink to Page3: <A HREF="page3.php?data=_POST">continue</A>


As far as I know, you could only do this if your hyperlink was actually a
submit button of a form which was pre-filled in with the values you want to
pass on - which would require javascript and is more of a bodge than a real
solution. If theres not much data you could use GET, which can just be
added onto the end of the hyperlink as you show, but not with POST, which
can be much much longer. I would still recommend sessions for this - then
you only need to pass the session ID (which is automatic in most cases
anyway) and then the rest can be left in the session. Unless your server
hasn't been updated for quite some time, it should have session support and
i can't think of any disadvantages to using that instead of passing
variables around multiple times from many pages - apart from anything else
if it is a lot of data then its being sent to and from the client at least
twice more then what it needs to.

David
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.