I would like to detect users country, so to preselect it in drop-down list in my php form. I tried to do it by getting users ip address and then I used Maxmind Geoip to get country name from ip. Everything works fine except when user is behind vpn, and this is when I cannot get the real ip (and so the country) of user if he/she is behind proxy or use VPN.
I read some similar post such as How to get Real IP from Visitor? and What is the most accurate way to retrieve a user's correct IP address in PHP?, and tried $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_X_FORWARDED_FOR'], getenv('REMOTE_ADDR'), etc. but none of them returned original ip when I am behind vpn.
I am really interested to know if there is any way to get the user real ip (e.g I am very curious to know how some websites like http://whatismyip.com return the original ip?). If really it is not possible to obtain this original ip in php as is said in this post, is there any other way to detect user country? (I also thought about browser language, but I think it would not be useful in my case, since e.g many users might set it to English while they belong to other countries)
Any idea would be highly appreciated,