Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Welcome to the TechnoWorldInc! Community!
Recent Updates
[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]

[February 14, 2024, 02:00:39 PM]

[February 14, 2024, 02:00:39 PM]

[February 14, 2024, 02:00:39 PM]

[February 08, 2024, 10:26:18 AM]

[February 08, 2024, 10:26:18 AM]

[February 08, 2024, 10:26:18 AM]

[February 08, 2024, 10:26:18 AM]

[November 27, 2023, 06:32:12 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » PHP
 Getting your Visitor's Details Using PHP
Pages: [1]   Go Down
  Print  
Author Topic: Getting your Visitor's Details Using PHP  (Read 2299 times)
Daniel Franklin
TWI Hero
**********


Karma: 3
Offline Offline

Posts: 16647


View Profile Email
Getting your Visitor's Details Using PHP
« Posted: September 26, 2007, 01:01:42 PM »


The following information is captured using the server variable ($_SERVER) which is available from PHP 4.10 onwards.

<strong>Visitor's IP address :</strong>

You can get the visitor's IP address using the following command:
<table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><? $ip = $_SERVER['HTTP_CLIENT_IP']; ?></td> </tr> </table>

This will give you the vistor's IP address. You can use this along with an ip to country converter database to see from which country your visitors are come in from. You can head over to http://ip-to-country.webhosting.info/ for one such script.

You can use PHP to resolve the ip address to a domain name to get the visitor's ISP in most cases. The ISP's domain will show up if PHP is able to resolve the IP to a proper domain. You can do this as follows.
<table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><?
$ip = $_SERVER['HTTP_CLIENT_IP'];
$visitor_host = @getHostByAddr( $ip );
?></td> </tr> </table>

Note : On some servers, using getHostByAddr to resolve domains may cause the script to slow down.

<strong>Referring Page :</strong>

You can capture the referring page, which will give you an indication of which site is sending traffic to you.
<table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><? $referrer_page = $_SERVER['HTTP_REFERER']; ?></td> </tr> </table>

This will give you the entire URL from which the visitor came to your site. For example if the visitor came from a google search for "i-pod", the referrer url would look something like this :

http://www.google.co.in/search?q=i-pod&;hl=en&lr=&ie=UTF-8&start=50

If you don't want the entire URL captured, but just the domain name stored into the database, you can strip the rest of the URL and save it to the database like so:
<table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><?
$referrer_page =
parse_url(htmlspecialchars(strip_tags($_SERVER['HTTP_REFERER'])));
?></td> </tr> </table>

This will save the referring page as :

http://www.google.co.in/

<strong>The page being Accessed :</strong>

You can also capture the page being accessed on your server. This information will help you evaluate which parts of your site is getting more page views.

A more advanced user can also use this information to create a click-stream of the user. A click-stream is the path that a user follows while he goes through your site. This lets you see how effective your site's navigation is.
<table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><? $requested_page = $_SERVER['REQUEST_URI']; ?></td> </tr> </table>

If the visitor is accessing your page, http://www.yourdomain.com/guestbook.php, the requested page would be 'guestbook.php'.

These pieces of information will help you build a visitor tracker in PHP, which will be able to tell you quite a bit about your visitors and how they use your site.
Articles Source - Free Articles

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.105 seconds with 24 queries.