1

I've been doing PHP for a while now, never needed assistance, but totally confused this time. I have a single line of code with one echo statement.

Problem: URL parameters are automatically assuming PHP variable values of the same name. For example, I have a URL with a parameter named var_name like this:

http://www.example.com?var_name=abc123

and a 1-line PHP script with a variable named var_name, like this:

echo $var_name;

then I get output on the page of: abc123

This is the only code in the PHP page! This behavior is exactly how I expect $_GET to work, but I'm not using it.

I am having this problem only on 1 specific server, which is running PHP 5.2. I have tested on 4 other servers, none have this behavior. I assume it's a PHP config issue, but running default config and can't find anything in config documentation.

MrWhite
46.4k9 gold badges67 silver badges89 bronze badges
asked Nov 19, 2010 at 0:40

2 Answers 2

6

This is called register globals. If a server has register globals turned on, then you can do this.

I would recommend not to have register globals on any server. Since it can introduce a security flaw in your system.

An example of a security flaw with this.

if($auth == true)
{
 // sensitive stuff here
}

If auth is just a regular variable, then I can do this in the URL.

http://www.example.com/page.php?auth=true

And see the sensitive information.

answered Nov 19, 2010 at 0:42
1
  • Thanks for the quick response. Never used register_globals, never want to again. That's a gaping hole of vulnerability. Thanks guys. Commented Nov 19, 2010 at 0:55
0

You probably have register_globals enabled:

See the manual for info.

answered Nov 19, 2010 at 0:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.