Tracking Visitors IP address in PHP

Sometimes in our mind being advanced to know about who are the people visit my website or blog.  Its very much important to improve feature and content of website according to visitor behavior. In here i’m trying to track visitors ip address using php language. So people enjoy it…

find-ip-trace-ip-address-track

<?php

function get_visitor_ip()
{
    if($_SERVER){
        if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
            $ip_adress = $_SERVER['HTTP_X_FORWARDED_FOR'];
        elseif(isset($_SERVER['HTTP_CLIENT_IP']))
            $ip_adress = $_SERVER['HTTP_CLIENT_IP'];
        else
            $ip_adress = $_SERVER['REMOTE_ADDR'];
    } else {
        if(getenv('HTTP_X_FORWARDED_FOR'))
            $ip_adress = getenv('HTTP_X_FORWARDED_FOR');
        elseif(getenv('HTTP_CLIENT_IP'))
            $ip_adress = getenv('HTTP_CLIENT_IP');
        else
            $ip_adress = getenv('REMOTE_ADDR');
    }

    return $ip_adress;
}
?>
Advertisements

Software Engineer at The Jaxara IT Ltd , Dhaka , Bangladesh

Tagged with: ,
Posted in PHP
2 comments on “Tracking Visitors IP address in PHP
  1. I’m not sure exactly why but this website is loading extremely slow for me. Is anyone else having this issue or is it a issue on my end? I’ll check
    back later on and see if the problem still exists.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: