Forum Moderators: coopster

Message Too Old, No Replies

Coding within “RegisterGlobals” off parameters

Guide Lines

         

henry0

12:24 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is my quest:
Most of my coding passes the test
One work (many scripts combo) does not
What are the most reliable rules in writing with registerglobals off
Any sound tutorial?
If I need to re do the whole thing I’ll rather do it thoroughly and the correct way

Thank you

Regards

Henry

Birdman

12:39 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suppose the mostimportant thing is to always refer to your globals with the full name ($_POST["var"], $_GET["var"], etc.)

You could probably fix your scripts easily by using extract() at the top of all scripts that use the globals.

<?php
extract($_POST);
...

Then you can refer to them by their index name ($var)

henry0

12:53 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Birdman
sounds like a good option
Henry

tomda

12:59 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is what I use (modify GET/POST)

if(isset($_POST["p"])) {$p = $_POST["p"];} else {$p = "";}

So that you are sure to have a defined variable in your script (NULL or NOT NULL)

Hope this help

Tommy

ergophobe

7:17 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Henry0,

I just had the reverse problem. I have always kept register_globals off, but recently uploaded something to a shared server that had registers_globals on. My app crashed. Why? Because in my mind (and by default in PHP), $_POST['id'] is not the same as $id. I mean $id is not the same as $ID, so it makes sense. But with register globals on, that is not respected.

Many people say that register_globals off is for security reasons, and it does provide a tiny bit more security. However, the reason they taught us to avoid globals back in my first programming courses (that was FORTRAN 77 folks), was not for security, but for code stability, maintainability and to make it easier to turn out stable code in a team environment.

So... that windy prelude leading up to this - turn register_globals off on your development platform and everywhere else you can, either in php.ini or in .htaccess (as I had to do on the shared server). Your programs will be more stable and maintainable in the long term. To me, the time savings from using globals is short sighted.

Tom

henry0

8:39 pm on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello Ergophobe
interesting point
thank you for your comments
stange enough I was thinking about the same line
(reverse problem) that answers it
Henry