Script for IP detection to deliver specific page?

by 3 replies
4
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
#programming #deliver #detection #page #script #specific
  • getting the IP in php:
    $ip = getenv("REMOTE_ADDR") ;

    country detection:
    ww w. maxmind . c om / app/php
    • [1] reply
    • For odd/even you want:

      $parity = ip2long($_SERVER['REMOTE_ADDR']) & 1;
  • 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.

Next Topics on Trending Feed