Getting URL parameter from redirect URL

5 replies
How do I get URL parameter from redirect URL?

Like the redirect url here is

a-domain.com/tracking/go.php?c=variables&s={keyword} which will be
redirected to b-domain.com/landing-page.php

I want the parameter of the redirect URL "{keyword}" to be received by the final page and show it up in b-domain.com/landing-page.php

I have used the following code in b-domain.com/landing-page.php:

<?php
$target = $_GET['s'];
?>
<h1>Welcome <?php echo $target; ?> Visitors!!!</h1>

But it's not working. Can anyone help me in this?
#parameter #redirect #url
  • Profile picture of the author BrainyBiz
    You would have to redirect to:

    b-domain.com/landing-page.php?s={keyword}

    You will need to pass the query string for 's' to the page on b-domain.com to be able to get the variable. You would then use your original code on b-domain.com/landing-page.php.

    Code:
    <?php
    $target = $_GET['s'];
    ?>
    {{ DiscussionBoard.errors[9119567].message }}
  • Profile picture of the author luther88
    first of all, never output anything that can be manipulated without first sanitizing it:

    $target = htmlentities($_GET['s']);

    that way you prevent XSS

    now, to come back to your question: you have to pass the paramter along to your final page if you want it to be available there

    depending on how you redirect to the page, it should be something like this:

    header("Location: http://b-domain.com/landing-page.php?s=".$target);

    then you can use this parameter on your page.

    If you do not want to show the parameter in the url you can store it in a session variable
    {{ DiscussionBoard.errors[9119572].message }}
    • Profile picture of the author crams
      You do have cpvlab, use it and make sure you check this.

      either if you;re direct linking to offer or using landing page you'll need to have "pass target" checked.

      not sure adtrackzgold will be able to pass variables through a redirect.

      and use
      <?php
      $target = $_GET['s'];
      ?>
      <h1>Welcome <?php echo $target; ?> Visitors!!!</h1>
      {{ DiscussionBoard.errors[9120060].message }}
      • Profile picture of the author crams
        have you tried using your redirect like this?
        a-domain.com/tracking/go.php?c=variables&s={keyword}&cpc=55&u=b-domain.com/landing-page.php?s={keyword}&p=all
        {{ DiscussionBoard.errors[9120150].message }}
  • Profile picture of the author wpbasit
    You can use JavaScript to determine the last url which is (a-domain.com/tracking/go.php?c=variables&s={keyword}) at your final page and then parse the keyword from that URL string using RegEx.
    {{ DiscussionBoard.errors[9151552].message }}

Trending Topics