Hello Friends I was Developing an website which i only want to be viewed by Indian (People of india) , and I Want to Get The Two Digit Country Code for that using php. I browsed to http://php.net and tried using geoip_country_code_by_name
, geoip_country_code3_by_name
and geoip_country_name_by_name
but None of Function worked , I have tried on my Existing XAMPP Installation and W3schools PHP runner but it says function not exists and i also have checked to PHP version. What Should i Do. I also Have tried methods form here and after Google(ing) whole day i finally came to ask here .
Feel Free to Suggest Edit or Close this Question
Asked
Active
Viewed 190 times
1

Devanshu Sharma
- 23
- 5
-
If I understand you correctly, you want to know the country of origin of the person who is viewing your website and block access to people from other countries - that's one. And number two is also identifying the indian country itself of the person. If I am right what you need to do is not solvable by a function... origin of viewer is found via ip and dns... which you can get through php alone. but you also need a service to check the ip data through and receive from it the origin information (also your two digit codes). There are free services such as MaxMind I believe. – Shlomtzion Aug 09 '21 at 17:06
-
https://stackoverflow.com/questions/10821974/how-to-make-geoip-country-name-by-name-work – ADyson Aug 09 '21 at 17:06
1 Answers
1
Based on some research, the best way seems to be by IP. This link will help you if you go this way. https://stackoverflow.com/a/13600004/13604954
But some VPN can easily change is on IP. ref. https://nordvpn.com/blog/vpn-ip-location-changer/
So good luck!
The easiest way will be to asking the user is country and if not what you want, just show another page.

Patfreeze
- 680
- 6
- 16