> My understanding is that when passing a querystring to PHP via the URL
> with the GET method, PHP will automatically create a variable with the
> name and value from the querystring. I'm trying to do this and it's
> not working.
Yes, if you have:
example.com/foo.php?id=33
In the old days, people used to rely on register_globals
($id to exist) but times have recently changed, people are
encouraged to move away from this potential security gotcha.
Some options within foo.php are:
// As of PHP 3 (forever)*
print $HTTP_GET_VARS['id'];
// As of PHP 4.1.0 (superglobals)
print $_GET['id'];
print $_REQUEST['id'];
// As of PHP 4.1.0, see also extract()
import_request_variables('gpc', 'r_');
print $r_id;
// If you have the PHP directive register_globals
// enabled. This defaults to off as of 4.2.0.
print $id;
Many options, choose for your needs. Read more here:
http://www.php.net/manual/en/language.variables.predefined.php
> Everything here works - I've already loaded the $myrow with the
> appropriate data and so this printf builds a URL with a valid '?id='
> querystring.
>
> But when I click on the URL, the variable is not created. I've tried
> renaming the variable, querying $HTTP_GET_VARS to see what's coming
> in, and looking at all available online documentation, but nothing
> helpful. There doesn't seem to be anything in php.ini I need to set
> to enable this functionality.
A simple way to test what information is available is to
use phpinfo() or simply print_r($_GET) for GET. Regarding
your specific question, see the above words and:
http://www.php.net/manual/en/security.registerglobals.php
Regards,
Philip Olson
* Assumes the PHP directive track_vars = on, which it always
is past 4.0.2.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php