Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting information about site visitors. 1

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
Hi

I am new to PHP, and have just set up a few basic scripts, to get some information about my site visitors.

At the moment I get Date and Time, IP Address and HTTP Referrer (which never gives me anything).

Is there anything else I can get about who a visitor is using PHP?

Things I would be particularly interested in is

+ What ISP the visitor is using

+ Country the VIsitor's IP Address is from. (I originally tried to get this using but they took their database down, and since I dont have SQL with my hosting plan, I am kind of snookered.)

+ Any other interesting (and useful) information that PHP can get me, but which I havent yet thought of.


Many thanks in advance.
RM
 
Run phpinfo() which will give you all the environment variables.
 
phpinfo() will only give you information about the server that it is running on. You can get very limited information about the request bu there are other php command for that eg. $_SERVER['varName']
I dont have the full list of variables on me now.
I also think there are other php function to get infomation, but I cant hink of any right now.
 
ISP information may be available via a whois query to the appropriate regional IP address authority: ARIN, RIPE, APNIC and LACNIC. (For more information, see
Each regional authority can point you to the correct authority if the IP address in question isn't in that region's database.

A whois query on an IP address to one of the regional authorities may return more than one value. If a company has leased an IP address range from UUNET, then a single whois query may show that a larger netblock containing the address in question is assigned to UUNET, and a smaller netblock containing the address is assigned to the company.

This should get you the ISP of the IP address in question. PHP does not have a builtin function to do whois queries, so you'll have to use socket functions or the PEAR whois class to do this.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Don't discount phpinfo() too quickly. phpinfo() gives the full list of variables that Westbury is trying to recall, such as SERVER["HTTP_USER_AGENT"]

The only useful data is the user's IP address, which can be cross-referenced to determine the hosting provider. Even this IP address data is nebulous as many users may access your site through a proxy.

For more detailed tracking of users, you will need to crumble a cookie crumb or use sessions to track how many times they come (and return) to your site.

If you want more info about your users, ask them with an input/feedback form.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
For converting IP address to geographic location, I use
Very useful, combines info from ARIN RIPE and APNIC, shows you a map and retrieves all sorts of extra info like the weather and timezone of the city the IP is from. Also displays WHOIS data.

Hint: if you don't want to manually type in the IP you can put a form on your page that calls the script that findthisip uses.

----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
 
Thanks Master.

That looks like a useful source to get country.

I tried using a PHP script that provided to get country information, but they recently took their server down because it was getting abused.

Are you suggesting I would be able to do a similar thing to grab country information from ?

I had a look on their site but couldnt see any PHP code that could be used like this.

Have you seen/got any?

Thanks again, that is a useful site.
RM
 
This is the (mainly HTML) code i'm using to bring up their page with info about an IP that i've got stored on my database from a visitor to my site:
Code:
<form method=&quot;post&quot; action=&quot;[URL unfurl="true"]http://findthisip.com/ftip.pl&quot;>[/URL]
<input type=&quot;hidden&quot; size=&quot;10&quot; name=&quot;ip&quot; value=&quot;<? echo $ip; ?>&quot;>
<input type=&quot;submit&quot; value=&quot;Locate&quot;>
</form>

where $ip is the variable where you have stored the ip address you want to lookup.

----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top