Redirect to external URL

Discussion in 'PHP' started by Omzy, Jan 18, 2009.

  1. #1
    How do I set up one of those redirect URLs that redirect the user to an external URL, for example:

    /clickthrough.php?businessId=4805

    Also if I did this would this be classed as a backlink for that site in terms of SEO?
     
    Omzy, Jan 18, 2009 IP
  2. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #2
    well to do that you just create a script that processes the $_GET data (the $businessid=4805) bit... so i'd do

    $id = $_GET['businessid'];

    and then something like using a MySQL query to select the row from a database of links... then just use the header function... so basically:

    $id = $_GET['businessid'];

    $link = "Select ".$id." FROM links";

    then sort that use a mysql_query to get the link.

    following it with

    header("location: ".$whatevervariablelinkisstoredin."");

    that's my glance over of it xD
     
    Grit., Jan 18, 2009 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Perhaps $id = intval($_GET['businessid']); just to be on the safe side.
     
    Danltn, Jan 18, 2009 IP
  4. Omzy

    Omzy Peon

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the responses guys.

    Danltn - what difference would the intval make?
     
    Omzy, Jan 18, 2009 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Stop MySQL injection attacks.

    Also do you not mean SELECT url FROM table WHERE id = $id LIMIT 1;
     
    Danltn, Jan 18, 2009 IP
  6. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #6
    Yeah... i was just giving a basic ideaology of it for him
     
    Grit., Jan 18, 2009 IP
  7. blackberryseo

    blackberryseo Well-Known Member

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #7
    Disalow the php redirect page from the robots.txt if you wish to not have a link from your site counted as a backlink to the linking site. Everything else has been mentioned above.
     
    blackberryseo, Jan 18, 2009 IP