Welcome to %1$s. Please log in.

Login with username, password and session length
 
News: Welcome to the TechnoWorldInc! Community!
Techno World Inc - The Best Technical Encyclopedia Online! | Forum | THE TECHNO CLUB [ TECHNOWORLDINC.COM ] | Programming Zone | PHP | Getting your Visitor's Details Using PHP

Daniel Franklin

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

Visitor's IP address :

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.

Referring Page :

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/

The page being Accessed :

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

Recent Updates

[August 11, 2025, 08:33:44 AM]

[August 11, 2025, 08:33:44 AM]

[August 11, 2025, 08:33:44 AM]

[August 11, 2025, 08:33:44 AM]

[May 13, 2025, 08:34:25 AM]

[May 13, 2025, 08:34:25 AM]

[May 13, 2025, 08:34:25 AM]

[April 12, 2025, 08:24:20 AM]

[April 12, 2025, 08:24:20 AM]

[April 12, 2025, 08:24:20 AM]

[April 12, 2025, 08:24:20 AM]

[March 12, 2025, 09:35:30 AM]

[March 12, 2025, 09:35:30 AM]

Subscriptions

<style>@import url('https://fonts.googleapis.com/css?family=Montserrat:700');@import url('https://fonts.googleapis.com/css?family=Montserrat:400'); .form-preview { display: flex; flex-direction: column; justify-content: center; margin-top: 30px; padding: clamp(17px, 5%, 40px) clamp(17px, 7%, 50px); max-width: none; border-radius: 6px; box-shadow: 0 5px 25px rgba(34, 60, 47, 0.25); } .form-preview, .form-preview *{ box-sizing: border-box; } .form-preview .preview-heading { width: 100%; } .form-preview .preview-heading h5{ margin-top: 0; margin-bottom: 0; } .form-preview .preview-input-field { margin-top: 20px; width: 100%; } .form-preview .preview-input-field input { width: 100%; height: 40px; border-radius: 6px; border: 2px solid #e9e8e8; background-color: #fff; outline: none; } .form-preview .preview-input-field input { color: #000000; font-family: "Montserrat"; font-size: 14px; font-weight: 400; line-height: 20px; text-align: center; } .form-preview .preview-input-field input::placeholder { color: #000000; opacity: 1; } .form-preview .preview-input-field input:-ms-input-placeholder { color: #000000; } .form-preview .preview-input-field input::-ms-input-placeholder { color: #000000; } .form-preview .preview-submit-button { margin-top: 10px; width: 100%; } .form-preview .preview-submit-button button { width: 100%; height: 40px; border: 0; border-radius: 6px; line-height: 0px; } .form-preview .preview-submit-button button:hover { cursor: pointer; } </style><form data-v-3a89cb67="" action="https://api.follow.it/subscription-form/QUJrWmZTYXZTNTJ5UDdYb2NaeVlQMmdRWTNQenUrdHdueldtWTNVOGk4WVJhVm94L280bzRPbFE1bVcwNDZ1UWJ4T0VFb0FETWJ4QjhhNGo3ekhGVXNRVmhkbXNnUDlZVkh6RWdmWWlveVVvWDZwbVNCcmpGZUVjMTBNN09WREN8dW1lOTY5VVhCNUtYZTJRdGRZV3ZSQWpaWVVpdGtqbjdNTC9HT2RlMndiaz0=/8" method="post"><div data-v-3a89cb67="" class="form-preview" style="background-color: rgb(255, 255, 255); border-style: solid; border-width: 1px; border-color: rgb(204, 204, 204); position: relative;"><div data-v-3a89cb67="" class="preview-heading"><h5 data-v-3a89cb67="" style="text-transform: none !important; font-family: Montserrat; font-weight: bold; color: rgb(0, 0, 0); font-size: 16px; text-align: center;">Get Latest Tech Updates For Free!</h5></div> <div data-v-3a89cb67="" class="preview-input-field"><input data-v-3a89cb67="" type="email" name="email" required="required" placeholder="Enter email" spellcheck="false" style="text-transform: none !important; font-family: Montserrat; font-weight: normal; color: rgb(0, 0, 0); font-size: 14px; text-align: center; background-color: rgb(255, 255, 255);"></div> <div data-v-3a89cb67="" class="preview-submit-button"><button data-v-3a89cb67="" type="submit" style="text-transform: none !important; font-family: Montserrat; font-weight: bold; color: rgb(255, 255, 255); font-size: 16px; text-align: center; background-color: rgb(96, 131, 190);">Subscribe</button></div></div></form>

Resources

  

Getting your Visitor's Details Using PHP

Started by Daniel Franklin, September 26, 2007, 07:31:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

  Print     Print       Print