IP Address PHP Script

Today, I need to find a simple code that show the user IP Address using PHP language.

I found a PHP code that only use remote address server like this example below:

Example 1

<?php

$yourip=$_SERVER[‘REMOTE_ADDR’];

echo “Your IP Address is”. $yourip;

?>

Example 2

<?php

$ipmu = getenv(“REMOTE_ADDR”) ;

echo “Your IP Address is ” . $ipmu;

?>

It’s very simple PHP code.

However, when your visitor use a free proxy server, the examples code above can not showing their real IP Address.

How to solve this problem?

Example 3

<?php

if (!empty($_SERVER[“HTTP_CLIENT_IP”]))

{

//check for ip from share internet

$yourip = $_SERVER[“HTTP_CLIENT_IP”]; }

elseif (!empty($_SERVER[“HTTP_X_FORWARDED_FOR”]))

{

$yourip = $_SERVER[“HTTP_X_FORWARDED_FOR”];

}

else

{

$yourip = $_SERVER[“REMOTE_ADDR”];

} echo “Your Real IP Address is”. $yourip ; ?>

The original PHP code is created by xpertdeveloper.com admin.

He said that it will detect the visitor’s real IP Address information. It does not matter if user using proxy or not. Is it true?

I am not sure. I think you need to run the PHP code above in your test page site.

The next step, visit your test page site from free proxy surfing site.

You will see the result.

Sometimes, I use a GSM provider for browsing. It’s cheaper than a broadband connection. Unfortunately, it has dynamics IP Address which used by thousand of peoples in my country. I has a different IP Address when re-starting my notebook.

If one of affiliate member that you registered using the same IP address, maybe It will make a problem for you. The affiliate admin will think you has double accounts.

Therefore, you can visit http://networktools.pro/ip-blacklist-check.php to search your IP Address status.

Thanks for reading 🙂