Jump to content

how to get IP address?


jacko310592

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.