I serve my PHP script with port forwarding(i use mamp) other users can view website but php don't return true client ip, it always return my server ip. I can't find my vpn ip in $_SERVER array what is problem? thanks.
Asked
Active
Viewed 347 times
0
-
possible duplicate of [How to get the client IP address in PHP?](http://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php) – Lfa Aug 16 '14 at 22:53
-
no any code in that question don't work (they always return my server ip) – user3803717 Aug 16 '14 at 23:09
1 Answers
0
To obtain ip address of clients from the server use $_SERVER['REMOTE_ADDR']. And to do it on client side using javascript and ajax for retrieving and sending ip address. see this link http://jsonip.com/

flo lab
- 19
- 2
-
The OP said they are using port forwarding. REMOTE_ADDR is going to have the IP of the machine doing the forwarding, not the original client. – Quentin Aug 17 '14 at 05:55