In PHP, you can use the gethostbyaddr(); function to get the host address, which usually includes the city/state in a proprietary format, however I am curious to know if there is another way to pull city's and states. From what I understand, most services have a big database of all the hostnames, and it will check with that and then parse out the location in normal text, which seems pretty unreliable to me. Being that IP's change constantly that doesn't make a lot of sense to me, fairly inaccurate.
Perhaps: http://www.ip2location.com/ As used here: http://www.digitalpoint.com/tools/website-country/
Yes, like this. I don't need anything as robust, just the city and state in text. I'd prefer if I didn't have to buy some package and have to use their database for any of it though. They are not very accurate half of the time unfortunately.
Hey ...I was looking for such kind of a software...however I learnt this new code of PHP script from ur post. But in India there is no open IP for the individual users, so in that case, will it be easy to track individual location specifically?
I think you should start looking here http://www.maxmind.com/ That's what most people seem to be using. There are free solutions as well, but as you said they are not so reliable.
I have this bookmarked, a friend sent me a link to it a bit ago. It seems that there might be an addition that you have to install with apache... which means most shared servers can't use this... maybe. I could be wrong about that.
They have a pure php module. It should work on shared hosting as well. According to their website: http://www.maxmind.com/app/php The Pure PHP API is cross-platform, works on Windows as well as Linux, and does not require Apache, nor does it require the C API.