faqts : Computers : Programming : Languages : PHP : Common Problems : Errors

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 8 people (63%) answered Yes
Recently 5 of 8 people (63%) answered Yes

Entry

My Variables from a form aren't recognized on destination .php page, is this a configuration issue?

Jun 26th, 2004 00:17
Philip Olson, Adam Jenkins, Mark Whittemore, Knud van Eeden,


Odds are you unknowingly rely on the PHP directive named 
register_globals as given the following example:
  http://www.example.com/a.php?foo=bar
The variable $foo will not exist when register_globals is off and it's 
off by DEFAULT as of PHP 4.2.0 so instead you would use $_GET['foo'] 
or $_REQUEST['foo'] and all of this is further described in the 
wonderful PHP manual here:
  http://www.php.net/variables.external
This is also covered in various faqts such as:
  http://www.faqts.com/knowledge_base/view.phtml/aid/5314/fid/6
  http://www.faqts.com/knowledge_base/view.phtml/aid/31/fid/9
To see all configuration information create a file with the following 
code:
  <?php phpinfo(); ?>
It'll tell you your register_globals setting.  Consider modifying your 
coding habits to not rely on this directive being on.  The 
register_globals directive CANNOT be set at runtime (in your script) 
but can be set in php.ini or .htaccess