Results 1 to 2 of 2

Thread: Problem with URL redirection

  1. #1
    Join Date
    Oct 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with URL redirection

    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. If I shorten the link lie: http://samplesite.com then it will pick up the site and redirect without any problem.

    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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    PHP Code:
    <?php
    include_once('./inc/default.inc');
    $redir $_GET['lnk'];
    swomCreateClick("test"$redir);
    header("Location:$redir");
    ?>
    Two problems: there should be a space between the header name and value, and unencoded ampersands (&) in the URL will confuse the server. To solve this problem, you should urlencode() the URL (something like Javascript's escape()).
    Final code:
    PHP Code:
    <?php
    include_once('./inc/default.inc');
    $redir urlencode($_GET['lnk']);
    swomCreateClick("test"$redir);
    header("Location: $redir");
    ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •