I want to use visitors' city,state on a landing page.
I emailed beyond hosting and they told me geoip was already installed and to use the functions on this page to call them http://php.net/manual/en/book.geoip.php
I'm a noob, I know basic html, can figure out java script, no idea what to do here. I've googled trying to find more tutorials but they are all based of this site. I've copy and pasted exact code and slightly modified code and can't get anything to pop up on LP.
What is the script I have to use to be able to display the city,state of user?
use the javascript posted by besmir
http://stmforum.com/forum/showthread...highlight=part
It's a bit outdated, you can view all the functions it gives you by just calling the script
http://j.maxmind.com/app/geoip.js
Put this in <head>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
Than, where you want to appear:
region:
<script language="JavaScript" type="text/javascript">document.write(geoip_region_name());</script>
city:
<script language="JavaScript" type="text/javascript">document.write(geoip_city());</script>
Here is the official documentation: http://www.maxmind.com/app/javascript_city
Yeah, that's the one I know how to use, but want one that goes to geoip on my site and not maxmind.
Does anyone know how to use the php one in the link in OP?
Thanks
If you want to use the PHP one it's pretty easy ( however keep in mind results will be the same with the javascript if you use the free version ).
Put this code on the top of your landing page :
[PHP]
<?
$ip=$_SERVER['REMOTE_ADDR'];
$record = geoip_record_by_name($ip);
$country=$record['country_code'];
$region=$record['region'];
$city=$record['city'];
?>
[/PHP]
Now , put this code where you want the city / region to be displayed :
My city is <?=$city?> My region is <?=$region?>
If you are running a page with alot of traffic don't use maxminds link to their js they will block you lol, found this out the hard way.
<body>
<div id="wrapper">
<All the stuff that makes up your LP>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"</script>
<script language="JavaScript">
var country=geoip_country_name();
var region=geoip_region();
var city=geoip_city();
if(country=="")
country="US";
if(region=="")
region="New York";
if(city=="")
city="New York";
</script>
<p><script language="JavaScript">document.write(city+ ', ' +region);</script></p>
</div>
<div align="center" class="p-small">Copyright</div>
</div>
<script src="tracking" type="text/javascript"></script>
</body>
You could use our API for GEO IP Location, you just need to create an account at ProxyDeter.com and then you do the following:
<?php
$api = "YOUR_KEY"; // Your API key
$ip = $_SERVER['REMOTE_ADDR']; // IP Address
$type = "name"; // This can be code or name. Code will display the country code (US), and Name will display the countries name (United States)
$results = file_get_contents('http://www.proxydeter.com/api/country.php?api='.$api.'&ip='.$ip.'&'.$type);
$results = simplexml_load_string($results);
if (isset($results->errors))
{
echo $results->errors;
}
else
{
echo $results->country;
}
?>
Is the geolite city database accurate enough for PPV?
if using the PHP posted above is REMOTE_ADDR = /usr/local/share/GeoIP/GeoIPCity.dat (where I installed the date file) of the geocities lite?
I guess I need to figure out how to install the mod_geoip which means I need to figure out how to install the rpm package for apxs?
Thanks
successliv, Yeah geolite city database should work fine. As for installing it.. I didn't need to modify my server any at all.