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

When $GLOBALS fails..?? help

P: n/a
[PHP]
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET
function parseTempIDArraySession() {
$tempIDArray = $_SESSION['tempIDArray'];
$_GET = $_SESSION[$_GET['tempID']]; // RESET $_GET WITH SESSION ARRAY
get_to_post(); // $_POST = $_GET
foreach ($tempIDArray as $tempID) unset($_SESSION[$tempID]);
print_r("POST: "); print_r($_POST); print_r("<P>");
extract($_POST, EXTR_SKIP);
foreach ($_POST as $key => $val) $GLOBALS[$key] = $val;
unset($_SESSION['tempIDArray']);
}
[/PHP]

This function will take everything out of $_SESSION[$tempID] and put
it into $_GET and then into $_POST. Then it will take everything out
of $_POST and make everything global whether register_globals is on or
off.

It doesn't work, surprise surprise.

In fact, all that doesn't work is the part whereby everything that
eventually winds up in $_POST is never global. Once you leave the
function all the variables vanish.

I am having to do this elaborate methodology because I have a
requirement to do a file/database action upon a query string while
keeping the query string secure; therefore, the key=val pairs normally
found in the query string are in a $_SESSION variable. So ultimately
I have to extract everything from that session variable and put it to
an autoglobal that my server-side validation and action classes can
use: $_POST (it *only* uses $_POST and no other autoglobal!). I can
actually get it so that it reads $_POST, but I need to get the global
value for each key in $_POST available once again because of the fact
that a class method must have at least one value: $refAction, and
$GLOBALS['refAction'] does not even work!

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


P: n/a
Phil Powell wrote:
[PHP]
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET
function parseTempIDArraySession() {
$tempIDArray = $_SESSION['tempIDArray'];
$_GET = $_SESSION[$_GET['tempID']]; // RESET $_GET WITH SESSION ARRAY
get_to_post(); // $_POST = $_GET
foreach ($tempIDArray as $tempID) unset($_SESSION[$tempID]);
print_r("POST: "); print_r($_POST); print_r("<P>");
extract($_POST, EXTR_SKIP);
foreach ($_POST as $key => $val) $GLOBALS[$key] = $val;
unset($_SESSION['tempIDArray']);
}
[/PHP]


I am not even going to try to guess why you are doing this. Have a
look at the 'import_request_variables'
(http://www.php.net/manual/en/functio...-variables.php)
function.

/Marcin
Jul 17 '05 #2

P: n/a
solved it by the simplest means possible. Just added
"refAction=$refAction" to the query string and that was it.

Never knew about import_request_variables() but that is a good
function to study.

Thanx
Phil

Marcin Dobrucki <Ma*************@TAKETHISAWAY.nokia.com> wrote in message news:<cp*******************@news2.nokia.com>...
Phil Powell wrote:
[PHP]
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET
function parseTempIDArraySession() {
$tempIDArray = $_SESSION['tempIDArray'];
$_GET = $_SESSION[$_GET['tempID']]; // RESET $_GET WITH SESSION ARRAY
get_to_post(); // $_POST = $_GET
foreach ($tempIDArray as $tempID) unset($_SESSION[$tempID]);
print_r("POST: "); print_r($_POST); print_r("<P>");
extract($_POST, EXTR_SKIP);
foreach ($_POST as $key => $val) $GLOBALS[$key] = $val;
unset($_SESSION['tempIDArray']);
}
[/PHP]


I am not even going to try to guess why you are doing this. Have a
look at the 'import_request_variables'
(http://www.php.net/manual/en/functio...-variables.php)
function.

/Marcin

Jul 17 '05 #3

P: n/a
Phil Powell wrote:
solved it by the simplest means possible. Just added
"refAction=$refAction" to the query string and that was it.

Never knew about import_request_variables() but that is a good
function to study.


You may also want to take a look at this:
http://www.koivi.com/manual-php-globals/

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.