[adslot]
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.
PHP Code
PHP Code Output
Visitor IP address:
127.0.0.1Browser (User Agent) Info:
Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1Referrer:
http://www.wapguy.com
Its really a simple PHP code, but still useful for you to track your website visitors and provide a better web browsing experience for them.
Thanks A Lot Man !
There is something wrong here, variable $referred is not declared:
$referrer = $_SERVER[‘HTTP_REFERER’];
if ($referred == “”) {
$referrer = “This page was accessed directly”;
}
Thanks for the examples though!
$referrer != $referred
and dont forget this one 🙂
$hostname = @gethostbyaddr($ip);