Re: php3 / php4 vars - Submitted form doesn't work
| From: | Philip Olson | Date: | Wed, 29 May 2002 15:00:42 +0000 |
| Subject: | Re: php3 / php4 vars - Submitted form doesn't work | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99750@lists.php.net to get a copy of this message | ||
> So my question is : Are there differences between
> PHP3 and PHP4, in the manner of passing variables to
> a script ???
Sort of. There are many factors for using data from
outside of PHP, such as forms. For example, let's
assume:
<form method="GET" action="test.php">
<input type="text" name="foo" value="bar">
<input type="submit" name="submit">
</form>
Within test.php will be our information, but how
do we access 'foo' = 'bar' information? Good
question, many ways exist, such as:
// Works since PHP 3
print $HTTP_GET_VARS['foo'];
// Works since PHP 4.1.0
print $_GET['foo'];
// Works if the PHP directive register_globals
// is ON, which has been default to off since
// PHP 4.2.0
print $foo;
Most likely you are trying to access $foo while
register_globals = off. You may want to discuss
this topic a little with your host, and ask them
to turn register_globals back on until everyone
is happy/ready for this major change.
Is there such a thing as register_globals_runtime()?
Nope. But you can (if host allows) use .htaccess to
modify such directives. Also consider the functions
extract() and/or import_request_variables() too. I
did post a _version_ of doing this at runtime here:
http://bugs.php.net/bug.php?id=17428
It might help too. Also read:
http://www.php.net/manual/language.variables.predefined.php
Regards,
Philip Olson