Does anyone know of an easy way to show a different Image/Banner based on what Country (IP address) the visitor is from?? What I want to do is: If visitor is from US show Image 1 Elseif visitor is from Canada show Image 2 Elseif............. Else show image 99 Also I am using PHP, HTML or Java code is what I would like to use.
You will probably need to use a geolocation database. If you Google "geolocation database" you will get a range of free and paid options.
php will make the job really easy. Pick your geolocation provider - some are "faster" than others - pick one that makes an api call so that you don't have to maintain your own geolocation database. From the results you'll be able to get a short country code. Then on your script all you have to do is <img src="/images/banner<?php echo $countryCode; ?>.png"> Code (markup): and it will automatically go and find the right banner. In my case it would look for bannerNZ, @COBOLdinosaur would get bannerCA and you would get bannerDK fwiw this is what I use on one of my sites for an enquiry email sent internally $ip = $_SERVER['REMOTE_ADDR']; $host = file_get_contents("http://api.ipinfodb.com/v3/ip-city/?key={$myAPIKey}&ip={$ip}"); $host=explode(';',$host); $content .= "<tr> <td valign='top'>IP Address</td> <td>{$ip}<br/>{$host[5]}, {$host[3]}</td> </tr>"; Code (markup):