Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    register_globals Not Functioning Properly!

    We are currently having quite the dilemma when it comes to register_globals.

    We are setting up register_globals on a local, as-needed basis. We have a "test" directory on our server and have register_globals turned on locally for this directory. If you run phpinfo() within this directory, it tells you that register_globals are "On" for the local value and "Off" for the master value.

    However .. it seems that register_globals aren't actually enabled, despite what the phpinfo() information says. I run the following script to act as a simple test, as it's clear that I can't rely on the configuration settings themselves:

    Code:
    <form method="post" action="globalstest.php?result=1">
    <input type="hidden" name="testvalue" value="true" />
    <input type="submit" value="Click to Test" />
    </form>
    
    <?php
    
    if($_GET['result']) {
    	if($testvalue == "true") {
    		echo "<p>(POST) Register globals are on.</p>";
    	} else {
    		echo "<p>(POST) Register globals are <strong>not</strong> on.</p>";
    	}
    
    
    }
    
    ?>
    Can anyone provide any insight? We've tried the same thing on another server (both are running IIS) and we are having the same issue.

    Thanks!

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    register_globals should be off anyways as if you try to develop with it on your code, apart from potential security holes, will stop working with PHP6.
    A good way to check if register globals is on is this:
    PHP Code:
    <?php
    if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
    {
      
    // register_globals on
    }
    ?>
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    At this point, it's not any of my concern what the configuration files tell me. It's whether or not a very simple test of register_globals that I run (the script I pasted above) works.. at this point, it does not. My main question is whether or not the script I posted is a sure-fire way to test to see whether or not register_globals are enabled.

  • #4
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    I don't know why your test should not work, however this does work:
    PHP Code:
    <html>
        <head>
        
        </head>
        <body>
        <?php
        
    echo (TRUE == isset($_POST['test'])) ?
            ((
    TRUE == isset($test)) ?
                
    'register_globals is <strong>enabled</strong>.' :
                
    'register_globals is <strong>disabled</strong>.') :
            
    //'<a href="?test=1">Test if register_globals is enabled</a>';
            
    '<form method="post"><input type="hidden" name="test" value="1"><input type="submit" value="Test if register_globals is enabled"></form>';
        
    ?>
        </body>
    </html>
    dumpfi
    "Failure is not an option. It comes bundled with the software."
    ....../)/)..(\__/).(\(\................../)_/)......
    .....(-.-).(='.'=).(-.-)................(o.O)...../<)
    ....(.).(.)("}_("}(.)(.)...............(.)_(.))Ż/.
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
    Little did the bunnies suspect that one of them was a psychotic mass murderer with a 6 ft. axe.


  •  

    Posting Permissions

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