PDA

View Full Version : Problem with URL redirection


deanp27
10-14-2005, 09:07 PM
I am really getting desperate now. Hopefully someone will manage to help me on this. I have created a clck.php page that redirects the users when they click on the banner to the URL of the advert. The purpose of the extra page (clck.php) is to enable me to track the clicks and assign them to the members. Then I connect the clck.php with the front site of the website by giving the url the following format: http:www.mysite.com/clck.php?lnk=URL. When I put the mouse on the banner it shows the full link but when you actually click on the banner it doeasn't take all the link. For example if the link is
http://merchant.com&affid=xxx&refid=xxx&subaff=xxx it will only redirect you to : http://merchant.com&affid=xxx. It won't pick up the rest of the URL although when i put the mouse on the link it does show on the explorer bar on the bottom the full link.

Here is the code.

The clck.php is:
<?php
include_once('./inc/default.inc');
$redir = $_GET['lnk'];
swomCreateClick("test", $redir);
header("Location:$redir");
?>

The relevant part from the default.inc is:

function swomCreateClick($username, $link)
{
global $MySQL_LinkID;
$merch_id = swomGetMerchantIDByURL($link);
$date = date("m/d/y");

if(!(mysql_query("INSERT INTO swomOpenClickList VALUES(NULL, '$username', '$merch_id', '$date', '0')")))
echo(mysql_error());
}

I am really lost. Does anyone have any clue??

Thanks in advance

nikkiH
10-14-2005, 09:27 PM
I'm going to assume that's a typo up there and that the link is to a site that has a querystring, thus there are 2 question marks in the URL. That is not valid.

Either encode and decode the question mark that goes with their site or save the URL in session and then get it.

If that isn't a typo, you forgot the question mark. :D

deanp27
10-14-2005, 10:51 PM
I can't see the problem with the questionmark myself so its very likely I made a mistake in the code. Where exactly on the code is the problem with the questionamark?

nikkiH
10-17-2005, 02:06 PM
In your post, not the code.

For example if the link is
http://merchant.com&affid=xxx&refid=xxx&subaff=xxx it will only redirect you to : http://merchant.com&affid=xxx.

should be

http://merchant.com?affid=xxx&refid=xxx&subaff=xxx
and
http://merchant.com?affid=xxx
respectively.

Which means your full URL would look like this.
http: //www.mysite.com/clck.php?lnk=http://merchant.com?affid=xxx&refid=xxx&subaff=xxx

Which is invalid as a URI due to the 2 question marks.