jacko310592 Posted December 2, 2009 Share Posted December 2, 2009 hey guys, i have this code which is supposed to get me the IP address of my site visitors: <?php if ($_SERVER['HTTP_X_FORWARD_FOR']) { $ip = $_SERVER['HTTP_X_FORWARD_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } ?> but all i get back when i test it is: ::1 how come the IP isnt showing, and what does "::1" mean? thanks guys Quote Link to comment Share on other sites More sharing options...
waynew Posted December 2, 2009 Share Posted December 2, 2009 <?php $ip = $_SERVER['REMOTE_ADDR']; ?> Is all you need. Quote Link to comment Share on other sites More sharing options...
jacko310592 Posted December 2, 2009 Author Share Posted December 2, 2009 that gives me the same reply :/ any ideas? could it be possible that it is showing "::1" because im running the php from my PC at the moment? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 2, 2009 Share Posted December 2, 2009 that gives me the same reply :/ any ideas? could it be possible that it is showing "::1" because im running the php from my PC at the moment? I do believe that is an IPv6 address. :: is a shortcut to skip blocks that aren't assigned, 1 being the first possible address. Is your server set up to use this, or did you change any settings? EDIT: You're running it from your PC, 127.0.0.1 is localhost AKA ::1 I assume. Quote Link to comment Share on other sites More sharing options...
jacko310592 Posted December 3, 2009 Author Share Posted December 3, 2009 ahh, i see, it must be because im running it from my PC then, silly me :/ thanks for your time guys Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted December 3, 2009 Share Posted December 3, 2009 The same thing would happen on all other servers where you are using an IPv6 network interface. You can set Apache to explicitly only listen on the IPv4 loopback address, i.e. 127.0.0.1 if you wish. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.