3 Replies - 1441 Views - Last Post: 17 April 2011 - 03:55 PM Rate Topic: -----

#1 semaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 116
  • Joined: 24-November 08

Getting user's IP address

Posted 16 April 2011 - 05:07 AM

hello guys , i'm trying to know the user's IP address to do some calculations on visitors online and so ..

i've found that $_SERVER['REMOTE_ADDR']; returns the IP address , but i'm not sure is that IP address of the server where the pages are on it OR the ip of the user

cause when i tested it locally it returns me : 127.0.0.1 which is localhost
Is This A Good Question/Topic? 0
  • +

Replies To: Getting user's IP address

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,023
  • Joined: 15-July 08

Re: Getting user's IP address

Posted 16 April 2011 - 05:12 AM

From the PHP manual:

Quote

'REMOTE_ADDR'
The IP address from which the user is viewing the current page.


So yes, it is the user viewing the page. The reason you are getting 127.0.0.1 is because you are locally reading it.
Was This Post Helpful? 2
  • +
  • -

#3 semaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 116
  • Joined: 24-November 08

Re: Getting user's IP address

Posted 17 April 2011 - 05:00 AM

aha , ok thx dogstopper :)
Was This Post Helpful? 0
  • +
  • -

#4 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: Getting user's IP address

Posted 17 April 2011 - 03:55 PM

Just as a added note, you will get the user's outside or global IP address, which is whatever IP address assigned to their modem or local router by their ISP.

It does not display a inside or local IP address unless your within the same LAN.

Just wanted to note because some people expect the inside/local IP.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1