1

using $_SERVER['HTTP_CLIENT_IP'] is not providing the client's ip address.

What could be the reason?

John Slegers
  • 45,213
  • 22
  • 199
  • 169
Arti
  • 35
  • 1
  • 6
  • Client machine may be behind an proxy or a NATed network connection. Try HTTP_X_FORWARDED_FOR or REMOTE_ADDR as well – Surfrdan Jun 20 '16 at 11:52
  • 7
    [**How to get the client IP address in PHP?**](http://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php) – Ben M. Jun 20 '16 at 11:52

2 Answers2

3

Try $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST']. That will give you your clients remote IP.

Evis Bregu
  • 230
  • 1
  • 9
2

you can use:

  • $_SERVER['REMOTE_ADDR']
  • $_SERVER['HTTP_CLIENT_IP']
  • $_SERVER['HTTP_X_FORWARDED_FOR']
StevenTan
  • 111
  • 5
  • **NOTE:** Make sure you take look at [here](http://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php#comment50230065_3003233), before just using $_SERVER['HTTP_X_FORWARDED_FOR'] – leopold May 20 '17 at 15:41