Answer the question
In order to leave comments, you need to log in
How to correctly determine the user's ip?
Hello. I have a task to determine the address of the user who visited the site.
I found the database of cities and ip addresses and set it up for myself. But the trouble is that the ip address is determined strangely.
I define the ip address as follows:
There are services that determine your ip address, and so, for example, my ip address is defined by my script as 192.168.8.121. This ip address is not in the database of my ranges, and services that determine the city by ip will not find anything.
But the services that determine my ip give me a different address: 109.195.134.64. This address is already in the database and the city will be determined.
Please tell me what I'm doing wrong and how to do it right?
Thanks in advance to all who respond. $ip = $_SERVER['REMOTE_ADDR'];
Answer the question
In order to leave comments, you need to log in
Comrade, you urgently need to read about the "white" and "gray" ip addresses.
Apparently your site is running on your machine, and you yourself go to the local address.
And 109.195.134.64 is not the address of your machine, but of your router through which you access the Internet.
You need to spend an hour or two reading about the basic concepts of IP networks and routing.
Start here
https://en.wikipedia.org/wiki/%D0%A7%D0%B0%D1%81%D...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question