Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

directly use php's get post variable's name 2

Status
Not open for further replies.

keak

Programmer
Sep 12, 2005
247
CA
HI there,
I am working on a piece of code here now written by a previous developer.

There is a form submission with a couple variables passed over, and usually one would have to put a code like the following to access this variable.

Code:
$firstname=$_GET[firstname]

however, on this form handling page, the variable $firstname is just referenced and it seems to be returning the data just fine.

Is there a function/setting in php that allows for this feature? Perhaps in php.ini?

If so, does anyone know what the relevant line of code/setting is?

Thanks!
 
That's likely the register_globals setting in php.ini. Most new installs of PHP have it off by default, and I believe they only have it now for compatibility - they don't recommend you use it.
 
Yes, its called register_globals, and should be set to off.

However when set to on.
PHP will automatically create and populate variables with the form elements names.

so if you have a say a textbox named "mytextbox" PHP will create a variable $textbox, that contains the value of the element.
However this is a serious security risk, which is why PHP has it set to Off by default now.

You can read this for more info on why register-globals should be set to off.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
wow thanks for the quick reply guys !

Yes, I switched that off in my php.ini and the form stopped working.

Now that you mention, I do remember seeing a warning when installing mamboo or something to have this var switched off.


Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top