register globals changed to off, script breaks
| From: | Kevin Coyner | Date: | Thu, 30 Sep 2004 18:33:30 +0000 |
| Subject: | register globals changed to off, script breaks | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-198321@lists.php.net to get a copy of this message | ||
I had a couple pages that had used a few 'a href' links to create a URL
like this:
http://mydomain.com/profile.php?cid=6
When you clicked the link, it went to the profile.php page, which had
the following code snippet:
foreach($_GET as $varname => $value)
$formVars[$varname] = trim($value);
This worked great when the server had 'register globals' set to on.
However, desiring to tighten up the security of the server a bit, I
turned register globals to off.
Now the above code snippet doesn't work.
I've done quite a bit of searching and reading and haven't yet come up
with a similar substitute (and I'm still learning PHP) for creating the
variable array from the GET.
What does work is:
$cid = $_GET($varname);
But that is only for when a single variable is passed, not when a bunch
of them get passed and need to be put into an array.
Would appreciate any tips.
Thanks
Kevin