php ip location

2019-05-18 11:46发布

问题:

I have a simple question. Is it possible to redirect people in my website by the IP location?

Example: one person navigates on the site and when go to pay, if the ip location is from Portugal pay by bank transfer, if not pay by paypal?

sorry my english. thanks, Pedro Lopes

回答1:

In the end, it sounds like you only really care about which billing platform to send them to. It is far easier and more reliable to allow your users to select their country from a list of countries you support. This is both more accurate than the IP-based solution and it solves for travelers who may not be at their home computer. There are more potential issues with IP-based location in the link @Piskvor provided in the comments above.

For the example you gave, you could offer your standard billing address form. If the user selects a country other than Portugal, the bank transfer tender type gets disabled, and PayPal is selected.



回答2:

Of course and you can do it. But I thing that not so accurate.

In example I am from Corfu, Greece. My geolocation is always pointing in Athens Greece.

Another example. I have try to lock out a whole country from accessing my web site for a personal reason. But while that work good, is not perfect, still I have visits from that country.



标签: php location ip