Forums

Appending a get request to URL and echoing it in post? (4 posts)

  1. harveycarpenter2
    Member
    Posted 4 years ago #

    I've tried to do this by putting this in the header:

    <?
    $keywords = $_GET[’keywords’];
    ?>

    and then

    <? echo $keywords;?> in the title, and in the actual post using the PHP-exec plugin (put it in the title just to make sure it wasn't a problem with the plugin).

    The $keywords variable is empty though, even when I go to:

    myurl.com/?page_id=5&keywords=test

    I currently have the wordpress permalink set to default.

    Any ideas? Thanks.

  2. Otto
    Tech Ninja
    Posted 4 years ago #

    The PHP Exec executes all sources it finds in separate contexts. So you'll need to declare $keywords as being global in both sections in order for the information to pass through from one to the other.

  3. Ivovic
    Member
    Posted 4 years ago #

    try putting just $_GET[’keywords’]; in your phpexec code and avoid setting a global var.

  4. harveycarpenter2
    Member
    Posted 4 years ago #

    Thanks guys

    Woah, it worked, was exactly what you said. For anybody else with the same problem, it just needed a simple:

    <?php echo $_GET["keywords"]; ?>

    Many thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic