Getting URL parameter from redirect URL

by 5 replies
6
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?
#programming #parameter #redirect #url
  • 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'];
    ?>
  • 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
    • [1] reply
    • 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>
      • [1] reply
  • 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.

Next Topics on Trending Feed