Code for finding location information (city) of a user clicking a link to open a page
I m learning php.. I need code to find out the location information (city and country browser etc ) of a user who clicks a link( which opens another page ) and also sends that info to show on another page. kind of like tracking visitors. I have seen many widgets for such visitor tracking and it would really be helpfull if i could get the code for that. i need to add such patch to my website project and i am stuck on it.
"I need code to find out the location information"
You mean a WOEID (Where on Earth ID)?
More than anything: respect the privacy of end users, if they want you to know where they are from you can use this alternative method (an html form) I made for you:
?><!DOCTYPE html> <html> <head> <title>Where are you?</title> </head> <body>
<form target="_self" method="post"> <span style="clear:both;">Where are you from?</span> <input type="text" name="where" /> <br /> Check this if you would like us to write this data to a log: <input type="checkbox" name="permission" /> <br /> <input type="submit" name="s"> </form>
</div> </body> </html>
That should work, I did not bother to test it. It also records their answers to a logfile, and the very first PHP line lets you put a URL in the string to redirect them to a new page once they answer.
If you want to see how the pros do it, they send a pixel(1x1) and use long polling to constantly send information back between server and client. They piggyback information like this: google.com/16bit.gif?all_the_info_your_browser_will_give_up=always
Last edited by eval(BadCode); 04-25-2011 at 02:58 AM.
I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;
If you want to find a users location, there are many different ways to do this. All of which use some type of database to make the relation between the IP and the location. Here is an example, however it is not very well on target: