parse_str and session vars

From: Date: Mon, 04 Mar 2002 07:49:09 +0000
Subject: parse_str and session vars
Groups: php.dev 
Request: Send a blank email to php-dev+get-80669@lists.php.net to get a copy of this message
Hi, I have encountered an issue with parse_str, that I believe needs to be addressed - allthough I might be mistaken, and in that case feel free to ridicule me - and tell me to go to the general list :) Well... I want to be able to do something like this: file1.php: <? session_start(); session_register("foo"); $foo="bar"; ?> <form action="file2.php?foo=foobar" method="post"> <input type="submit" name="Go"> </form> file2.php: <? session_start(); $old=$foo; parse_str($QUERY_STRING); Header("Location: file3.php?old=$old&foo=$foo"); ?> file3.php: <? session_start(); echo "foo: $foo<br>"; ?> >From the manual: (explanation for parse_str) Parses str as if it were the query string passed via an URL and sets variables in the current scope. If the second parameter arr is present, variables are stored in this variable as an array elements instead. I would expect that the script would result in file3.php echoing, "foo: foobar" - but that's not the case, instead I get: "foo: bar", but the url is: "file3.php?old=bar&foo=foobar". Doesn't session_start introduce all the registered vars into the current scope - and since parse_str "sets varibles in the current scope" why doesn't this scheme work? Thanks for listening Thomas

« previous php.dev (#80669) next »