Gobal varible accross pages?

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
User avatar
oz
Forum Newbie
Posts: 11
Joined: Sun May 26, 2002 7:15 am
Location: Michigan
Contact:

Gobal varible accross pages?

Post by oz »

How do you keep the content of a varible accross web pages in the same site?

I tried the gobal command, but it doesn't seem to work, unless I'm doing it wrong.

gobal $refer;
$refer = $HTTP_REFERER;

then when I try to use $refer from another page it's blank.

Oz
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Hi,

When moving between pages it needs to be passed, either in the URL i.e. http://www.example.com/nextpage.php?refer=$refer

or

as a hidden form field.

or

you can use cookies or sessions. There is no magic that make them automatically appear between pages.

But if it is a server variable you are trying to retrieve it should be available on all pages, if you are using the latest version of PHP you need to look at the notes on http://www.php.net as there were changes to the way global variables are handled. If you can't find them, then search these forums for messages on $_POST, $_SERVER etc.

This has been answered many times now :cry:

Mike
User avatar
oz
Forum Newbie
Posts: 11
Joined: Sun May 26, 2002 7:15 am
Location: Michigan
Contact:

Post by oz »

but only once for me :wink:
thanks
Post Reply