Login
Connect via Facebook

Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Forum Threads
Users Online
Guests Online: 1

Members Online: 0

Total Members: 619
Newest Member: Pranav Adithya
Advertising
Donate
If you like our free products please donate us.

Advertising
View Thread
 Print Thread
Show user information
Admin
You might have seen some of the sites showing you the information like “Your IP address is 127.0.0.1 ” or “You are using Firefox browser” etc. Its really easy to display or get these user or visitor information using PHP codes. Here in this post, we will write a simple php code for displaying a visitor’s IP address, browser info and where that user came from (Http_Referrer i.e from which url the user clicked to get to your current page). This will be useful for you to keep track of your visitors or optimize the webpage for your users in a specific way depending on the browser or ip address etc.

Download source  GeSHi: PHP
  1. <?php
  2. /**
  3. * Show user information like IP address, useragent
  4. **/
  5. $ip = $_SERVER['REMOTE_ADDR'];
  6. $browser = $_SERVER['HTTP_USER_AGENT'];
  7. $referrer = $_SERVER['HTTP_REFERER'];
  8. if ($referred == "") {
  9. $referrer = "This page was accessed directly";
  10. }
  11. echo "<b>Visitor IP address:</b><br/>" . $ip . "<br/>";
  12. echo "<b>Browser (User Agent) Info:</b><br/>" . $browser . "<br/>";
  13. echo "<b>Referrer:</b><br/>" . $referrer . "<br/>";
  14. ?>
Parsed in 0.093 seconds, using GeSHi 1.0.8.10


PHP Code Output
Visitor IP address:
127.0.0.1

Browser (User Agent) Info:
Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1

Referrer:
http://www.wapguy.com
Edited by Admin on 27-12-2016 22:07
 
Jump to Forum: