Global 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
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Global Variables

Post by JackD »

We have 23 variable values we need passed from one page to another, rather than just string them into a long REST command, write them into a cache file, or write them to a mySQL database.

$_POST gets reset to the values of a form when a button is clicked. $_REQUEST only contains info from the current script.

Is there a SAFE global that can be used to pass values, ie, $_POST['partID'] = '1234', or is there a way to keep $_POST from being reset when a button is clicked. We are trying to stay with PHP and no get into JavaScript.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Global Variables

Post by josh »

you want sessions
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Re: Global Variables

Post by JackD »

I tried using $_SESSION.

Here is what is in detail.php:

$_SESSION['BFL']['mode'] = 'add';
..
..
21 other adds to $_SESSION.

At the end, $_SESSION is set as we would expect it to be. The submit button that is in detail.php invokes cart.php.

However, when in cart.php was invoked, $_SESSION comes in with only the content for httpreferer. Apparently, $_SESSION is getting reset just as is $_POST.
Post Reply