Changing Link depending on IP Address?

Discussion in 'PHP' started by Nang-Ex, Jul 7, 2009.

  1. #1
    I dont think if this is possible but what the heck.

    i got a sales page.. and at the bottom i have the "buy me" image.

    the proble is that i want to display different "buy me" links to specific IP addresses.

    Is this possible?


    For example..

    Everyone goes to my page and everyone sees this link

    www.mysite.com/buyme.html

    and one or some specific ips for example : 201.002.002.003

    they see this

    www.mysite.com/notforyourcountry.html


    got my idea?
     
    Nang-Ex, Jul 7, 2009 IP
  2. richrobert

    richrobert Guest

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is easily possible, google geoip redirection.
     
    richrobert, Jul 7, 2009 IP
  3. Nang-Ex

    Nang-Ex Peon

    Messages:
    253
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nope but you see i dont want to redirect any visitors to any page, i jsut want 2 have 1 page with just 1 link chaning if an specific visitor comes.
     
    Nang-Ex, Jul 7, 2009 IP
  4. richrobert

    richrobert Guest

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So it's just for one specific visitor? Only one ip address?

    Either way it doesn't matter, it's still easily possible with a bit of geo ip php...
     
    richrobert, Jul 7, 2009 IP
  5. Nang-Ex

    Nang-Ex Peon

    Messages:
    253
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yeah just for one IP. or maybe 2. its for a specific person i dont want them to see what i am selling.
     
    Nang-Ex, Jul 7, 2009 IP
  6. richrobert

    richrobert Guest

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ok, well if you just want to change the link for one ip...

    <?php

    $ip = $_SERVER['REMOTE_ADDR'];

    if ( $ip == "123.456.78.910" ) {
    echo "http://linkifbadip.com";
    } else {
    echo "http://everyoneelse.com";
    }

    ?>
     
    richrobert, Jul 7, 2009 IP
  7. Nang-Ex

    Nang-Ex Peon

    Messages:
    253
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    how can implement this on a IMG link?
     
    Nang-Ex, Jul 7, 2009 IP
  8. richrobert

    richrobert Guest

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Can you link me to your site?

    It would be something like...

    <a href="<?php

    $ip = $_SERVER['REMOTE_ADDR'];

    if ( $ip == "123.456.78.910" ) {
    echo "http://linkifbadip.com";
    } else {
    echo "http://everyoneelse.com";
    }

    ?>" target="_self"><img src="image.jpg" alt="whatever" /></a>
     
    richrobert, Jul 7, 2009 IP