Page 1 of 1

urls with vars in query string

Posted: Tue Oct 14, 2008 10:27 am
by php3ch0
I am writing a script to track pay per click and affiliate links from banners, adwords etc.

When the user clicks the links then it goes to this tracking script and stores the relevent data so that we can run reports on it. Then it forwards to the correct URL.

The problem is that the data and the url are provided by a third party who provide it in this sort of format:

part1:

should redirect to:
part2:


the bit in bold is causing the problems. Because of the extra & it is breaking the rest of the query string. The problem being becuase we cannot have any control over the url that is provided in part 1 nor do we have any control over the order of the URL variables. We also cannot do without the other vars as they are used as part of the tracking process.

Is there a way that we can get $_GET['redirect'] to be the correct part?

Re: urls with vars in query string

Posted: Tue Oct 14, 2008 11:00 am
by Ziq
You can use rawurlencode() and rawurldecode() php function.

Code: Select all

 
<?
//...
$redirect_url = "http://www.somehost.com/page.php?a=2";
echo rawurlencode($redirect_url);
echo rawurldecode($_GET['redirect_url']);
//...
?>
 
Or you can storage redirect_url in database (or somewhere else) and use url_id.

Re: urls with vars in query string

Posted: Tue Oct 14, 2008 11:20 am
by php3ch0
thanks for that will give it a try