Cannot pass variable with PHP (2 posts)

  1. mosley
    Posted 9 years ago #

    I am trying to a pass a variable with PHP in my blog. Here is my code:

    define('WP_USE_THEMES', false);
    <?php echo "'$myvar'";?>

    When I type "http://www.11thfloor.net/videos/test.php?myvar=test" into my address bar the variable does not pass. But when I remove

    define('WP_USE_THEMES', false);

    from my code the variable passes.

    Can someone help with this?

  2. The reason this is happening is that you appearantly have register_globals turned on by default (since you think that $myvar will contain that information passed in via the URL).

    Since this is a massive security hole, WordPress turns that off and unsets all the variables that were set when you call the wp-blog-header.php.

    register_globals should always be OFF. It defaults to off in the latest PHP versions, and you should really edit your php.ini to turn it off as well.

    If you want the contents of myvar, the correct way to get them is to access it via $_GET['myvar'] or $_POST['myvar'], depending on how it was sent to your script.

Topic Closed

This topic has been closed to new replies.

About this Topic