![]() |
| ||
| find county using ip address $url=$_POST['url']; $ip = gethostbyname($url); $long1 = ip2long($ip) if ($long1 == -1 || $long1 == FALSE) { echo 'Invalid IP, please try again'; } else { print $url; echo $ip ?> bu this code i get ip address but i need the country name aslo with this ip address. is thers any function to get country? thanks |
| ||
| Re: find county using ip address There is no function that identifies a country using the IP address. You will need to use a GeoIP (also called GeoLocation) database. There are several freebie GeoIP databases available. http://www.maxmind.com/app/geoip_country http://ip-to-country.webhosting.info/ |
| ||
| Re: find county using ip address Use <snipped>to get ip to country and other useful information. |
| ||
| Re: find county using ip address Hi Aatya, U can use the following function to get the country name from IP address. function countryCityFromIP($ipAddr) plz try it let me know what's result? |
| ||
| Re: find county using ip address Quote:
I used your script (with minor modifications - needed only to show the country) and it worked splendid. thanks pal. |
| ||
| Thanks KULDEEP04 ! I've copied and paste your code, set the Google IP and sure enough while running it, I can display the answer: City: Mountain View, CA Country UNITED STATES! That's great, Im going to use your code and leave your reference (URL) in it. My goal is to record myself from where and when the users hit my pages... I have a problem.. Maybe you can help me: To apply this code I must change my pages form ext: .HTML to .PHP: DO YOU KNOW IF THAT WILL AFFECT the ranking of my pages on search engines? Gravimotion |
| ||
| The file extension will not affect a new site, but it will affect an existing site that has already been indexed. The old page URLs in the search engines will generate 404 status codes (Page Not Found) unless you use a 301 redirect to redirect the old pages to the new pages. If you leave the file names the same and only change the extensions, you should be able to add the following to the .htaccess file to take care of the redirection. This will only work on an Apache web server. RewriteRule ^(.*)\.html$ /$1.php [R=301,L] Test it with a few pages to make sure it is working correctly. If you enter an old URL with the .html extension, you should see it change to the new .php page in your browser's address window. |
| All times are GMT -4. The time now is 3:36 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC