Getting Visitors IP Address

+2 Roopavathy Baskaran · August 14, 2014

First of all,I thank you a lot for your nice tutorials.Very useful teachings! Nice work !!! Keep it up!!!

I have followed your 65 & 66th Video -  Better Way to Get Visitors IP Address...But I am getting result as 

::1 for 65 th video and 

Notice: Undefined index: HTTP_CLIENT_IP in C:\xampp\htdocs\Ruth-PHP\Visitor_IP\Check_ip_way2.php on line 3

Notice: Undefined index: HTTP_X_FORWARDED_FOR in C:\xampp\htdocs\Ruth-PHP\Visitor_IP\Check_ip_way2.php on line 4

What's wrong with my program?Please help me.

Thanks in advance!!!!

Post a Reply


Oldest  Newest  Rating
+1 Franz Schmidt · August 14, 2014
Could you please post your code to? :ermm:
+1 Shamal Sandeep · August 31, 2014
Hey I noticed that some of the PHP tutorials are outdated and at the same time ip ::1 is the Ipv6 equivalent for in Ipv4. It's not an error so try to use it or convert it into using a php function.
+1 Jasmin Bakalović · August 16, 2014
I tested your code and instead of $_SERVER, I used getenv().

$http_client_ip = getenv('HTTP_CLIENT_IP');
$http_x_forwarded_for = getenv('HTTP_X_FORWADED_FOR');
$remote_addr = getenv('REMOTE_ADDR');

Probably you are asking yourself now, what is getenv()? With getenv() function you can access to any environment variable. More info:

And, if you worry about this ::1, it's your IPv6 adress => You can solve that problem by configuring apache setings:
+1 Roopavathy Baskaran · August 16, 2014
Thank you Jasmin....:)
0 Muhammad Zeeshan · August 28, 2015
It can be corrected  by replacing "localhost" in  url with "" and then it shows the ip:"" :)
0 Roopavathy Baskaran · September 1, 2014
Thank you..
0 Nikola Novakovic · September 1, 2014
IPV6 is honestly a little bit far into the future I think. I am not saying it is not awesome but it is still used really on a few occasions. It is not totally relevant to this but just sayin' :) 
0 Roopavathy Baskaran · August 16, 2014
Sorry for late reply............

Here is my code:




echo $ip_address;

0 Roopavathy Baskaran · August 16, 2014
Can anyone help me?
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.