www.webdeveloper.com
Results 1 to 7 of 7

Thread: register_globals info

  1. #1
    Join Date
    Aug 2009
    Posts
    3

    register_globals info

    Hi.

    I have a kind of old script for polls that I heavily modified it during years. The main code still there.

    Today i realize that is using register_globals On (tested new changes in a local xampp installation).

    Is there any good information regarding register_globals On|Off around to share?

    I need to prepare this script to register_globals Off but I don't know where to start.

    Any help is really appreciated.

    Regards,

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    You just need to make sure to get your values from the superglobal arrays ($_GET & $_POST) instead of assuming they will be set for you.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    The best solution is as Mindzai suggests: to ensure that your script explicitly gets external values from the applicable super-global arrays ($_POST, $_GET, or $_COOKIE). If you need a quik work-around to make something run that depends on register_globals until you can re-factor it, you can use the import_request_variables() function at the start of your script.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    437

    register globals

    You need to check whether your hosting provider has turned register globals off or on. You can use phpinfo to test that.

    If it is off, most hosting providers allow custom turning off/on of register globals based on a .htaccess file or php.ini file in the directory.

    You can use this interim solution till you change your script.
    Last edited by chrisranjana; 08-03-2009 at 08:02 PM. Reason: typo
    Chris, Senior Developer, Chrisranjana.com
    Php Programmers

  5. #5
    Join Date
    Aug 2009
    Posts
    3
    Well, first ... thank you for your answers.

    I tried what you recommend but I still have this problem:

    I found at least one variable that is passed along scripts: it's $login. Is set via a post in the Auth class from the "PHP Anthology" book 1st. Ed.

    I use this variable some place else to identify the user logged in but I don't see how this variable is passed from the class to the other script. Is this what register_globals is about?

    Basically the $login var is assigned:

    PHP Code:
    $login=mysql_escape_string($_POST[USER_LOGIN_VAR]); 
    and in some point this is used as:

    PHP Code:
    <?php echo "<p>Bienvenido(a) $login<br/><br />"?>
    With register_globals On is working but with Off is not.

    I am sure there are more variables just like this one, but I don't see how _GET or _POST are involved here. I dump those variables and get nothing:

    PHP Code:
    Dump GET
    array(0)
    Dump POST
    array(0
    Any idea?

    Thanks in advance

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    $_SESSION, perhaps?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Aug 2009
    Posts
    3
    Maybe. My problem is to figure out how many variables are in this case.
    It just happened to found this one.
    Last edited by notuo; 08-04-2009 at 03:32 PM. Reason: typo

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles