Jump to content

getting the client Ip


jimfog

Recommended Posts

I am trying to get the client IP using the following code:

$ip=$_SERVER['REMOTE_ADDR'];echo "<b>IP Address= $ip</b>";

The only the gets printed to the browser though is this:IP Address=::1 I am developing locally and as such the IP is 127.0.0.1-I believe this is that should beprinted in the browser.

Link to comment
Share on other sites

Yes that is why you're seeing that because of developing locally. Try making your server accessible from outside connections, then using another ISP, like a friends or cafe... or your mobile phone if you have one using the carriers connection(not wifi because it may connect to your local home wireless connection if you have one), you should see the actual IP address when using the above.

Link to comment
Share on other sites

Is there a way that I can bypass the problem and the local IP be printed in the browser. I am not doing it for experimentation purposes-I am developing an application in whichthe IP of the client has to be inserted into a table.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...