Hi Joey:
This is a fix that you can include in every script that needs it. See
also comments below.

if($GLOBAL_VARS_FIX) {
   if (phpversion() >= "4.2.0") {
      extract($_POST);
      extract($_GET);
      extract($_SERVER);
      extract($_ENV);
      extract($_COOKIE);
   }
}


On Tue, 2004-03-16 at 08:26, Joey Kelly wrote:
> Y'all,
> 
> I've got a sticky problem that I need to solve. I've just turned on 
> register_globals in my PHP php.ini file, and therefore have to run my form 
> variables through $_POST:
> 
> $variable = $_POST[$variable];
> echo $variable;

if register_globals = on

you can use print( $variable );

if register_globals = off

you MUST use print( $_POST['variable'] );


> The problem I'm having is that the script Im trying to refactor worked great 
> before I turned register_globals off. The script posts an array, and I can't 
> seem to figure out how to $_POST the array.
> 
> Here is the script with register_globals OFF:
> http://joeykelly.net/materials.php
> 
> Here is the script with register_globals ON:
> http://redfishnetworks.com/~jkelly/materials.php
> Notice the huge nested array at the bottom when you click [SUBMIT]? That's my 
> trouble.

> In both cases, changing the extension from .php to .phps shows you the source 
> code. As you can see, above the form I've tried several attempts to access 
> the data, all of which seem to fail.

changing extension only matters to how apache processes the file. If you
add the extension .phps to the apache.conf then .php and .phps will
behave exactly the same.

> My question: What am I doing wrong? I suspect that I'm having trouble with 
> nested arrays, etc.. The thing that bothers me is that the data is available 
> (see the array printout at the bottom?).
> 
> If I can't make this work, I'm going to have to resort to munging a bunch of 
> scalars ($quantity1, $quantity2, etc.), which to me is an awful kludge that 
> I'd rather not sign my name to.
> 
> Thanks for any help.

Reply via email to