icepay
Junior Member
- Jan 13, 2009
- 123
- 19
Instead of using
can i use like
to target banner ads?
and also I have ip2nation in my mysql database. I think it requires same coding?
Code:
case "US": header("Location: http://Your_American_page"); break;
can i use like
Code:
case "US": echo "<a href="http://Your_American_page">
<img src="http://Your_American_page/image.jpg"/></a>"; break;
to target banner ads?
and also I have ip2nation in my mysql database. I think it requires same coding?
I think max-mind has the best solution to do geo-targetting. It's quite easy to use and by using the geo-lite db it's free. You can do it all without MySQL and can update the geo-country db monthly, on the 1st of each month. Also since all calls are local once setup there are no http calls to external sites that may fail.
Based on the geo-targetting gimme4free requested here is how you would do it:
First download the binary db.
Code:http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
Next download the API
Code:http://geolite.maxmind.com/download/geoip/api/php/geoip.inc
Place both of these on your webserver and unzip GeoIP.dat.gz. Make sure the file that is created is called GeoIP.dat and if not rename it as such OR change the script to address the correct .dat file below.
Now here's the script that will use these to redirect based on the source location of the hit. Make sure this script resides in the same directory as the .inc and .dat file above.
PHP:<?php include("geoip.inc"); $ip=$_SERVER['REMOTE_ADDR']; $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, "$ip"); // Country name is not used so commented // Get Country Name based on source IP //$country = geoip_country_name_by_addr($gi, "$ip"); geoip_close($gi); switch($country_code) { case "US": header("Location: http://Your_American_page"); break; case "CA": header("Location: http://Your_Canadian_Page"); break; case "UK": header("Location: http://Your_U.K._Page"); break; case "AU": header("Location: http://Your_Australian_Page"); break; default: header("Location: http://Where_the_rest_of_the_visitors_go"); } ?>
Hope this helps somebody here!