Script for IP detection to deliver specific page?

3 replies
Hello All,

I was wondering if there exists a script that would do two things:
1) Determine the IP address of the site visitor country e.g India
2) and, based upon the IP address being either an odd or even number, display a particular version of a webpage. (Odd-numbered IP would show page version A, even numbered IP would show version B(Version B may be different URL))
---

As I am not an expert, I may be unaware of a problem with this idea, and please know that I am open to an even better approach!

Thanks,
Agraj
#deliver #detection #page #script #specific
  • Profile picture of the author McBob
    getting the IP in php:
    $ip = getenv("REMOTE_ADDR") ;

    country detection:
    ww w. maxmind . c om / app/php
    {{ DiscussionBoard.errors[3491837].message }}
    • Profile picture of the author RyanAndrews
      For odd/even you want:

      $parity = ip2long($_SERVER['REMOTE_ADDR']) & 1;
      {{ DiscussionBoard.errors[3492074].message }}
  • Profile picture of the author PaulChester
    If I were you I'd look at ip2nation dot com.

    It's free and there's a couple of decent php script examples to show you how to get the visitors IP address and query the database to find their country. I'm using it and I've had no problems with it.

    Paul.
    {{ DiscussionBoard.errors[3502265].message }}

Trending Topics