Re: Alternate To Making Form Variables Global (Clerified)

From: Date: Mon, 06 May 2002 23:36:19 +0000
Subject: Re: Alternate To Making Form Variables Global (Clerified)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-96330@lists.php.net to get a copy of this message
Dr. Shim wrote:
Sorry, I'll have to clerify myself a bit. I'm rather tired. :) I have a script that verifys and inserts (into and Access databse) form values. I had to make the form variables "global", in order to use them in my functions. Since the new PHP is out, the script doesn't work anymore. I think its probably because of the fact that I had to make those variables global (none of the variables are being read). Does any of you have an idea about how I can fix this problem? Thanks in advance. "Dr. Shim" <ultimatezzz@hotmail.com> wrote in message news:20020506231506.32237.qmail@pb1.pair.com... Is there another way then to register form variables global? I just downloaded, and instlaled the newest version of PHP, and now my form script doesn't work anymore. I had to register the form variables global in the script. I'm asking, is there a better way of doing this? I've herd it can lead to possible security hazards. Thanks for any help.
Look into the extract() function. You could use it to turn the $_POST or $_GET arrays into local variables, whether you do it at the beginning of the script and make them global as you are currently doing or by doing it at the beginning of the functions that you use them, without globalizing anything. For example... given the url http://localhost/foo.php?bar=banana you'd have $_GET['bar']=="banana" instead of $bar=="banana"; at the beginning of the script you'd have extract($_GET); and $bar would exist with the value "banana"

« previous php.general (#96330) next »