开发者

Access Forbidden using Xampp with Register_Globals Off

开发者 https://www.devze.com 2023-03-08 11:33 出处:网络
I recently learned that it is more secure to turn register_globals off in the php.ini file. However, when using the following script, it works when register_globals is turned on and when register_gl

I recently learned that it is more secure to turn register_globals off in the php.ini file.

However, when using the following script, it works when register_globals is turned on and when register_globals is turned off I get a Error 403 Access Forbidden message after I press the submit button:

    <?php 
         if (isset($_POS开发者_StackOverflowT['user']))
         {
             $user = $_POST['user'];
         }
         if (isset($_POST['address']))
         {
             $address = $_POST["address"];
        }

        if (isset($_POST['submit']))
        {
              echo "Welcome, ".$user. ". <br>";
              echo "Your address is: ".$address;
        }

    ?>

    <html>
    <head>
    <title>Personal Info</title>
    </head>
    <body>
    <form method="post" action = "<?php echo $PHP_SELF;?>">
       Name: <input type="text" name="user">
       <br>
       Address: <input type="text" name="address">
       <br>
       <input type="submit" value="submit" name="submit">
    </form>
    </body>
    </html>

What am I doing wrong that I get this error message only when register_globals is turned off. I am on Windows XP, I am using Xampp 1.7.4, and I am a noob :)


$PHP_SELF must be $_SERVER['PHP_SELF'].


Use $_SERVER['PHP_SELF'] instead. The presence of $PHP_SELF is a side effect of register_globals being on.


$PHP_SELF depends on register_globals. Use

$_SERVER['PHP_SELF']

instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号