php ip location

456

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

804

Answer

Solution:

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.

391

Answer

Solution:

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.

435

Answer

Solution:

Yes. It is totally possible to track and redirect based on visitor's IP-Location.

You can use ipgeolocation.io API. It is free for use up to 30K requests per month (1K requests per day). It has integrations available for many languages like PHP, Java, etc.

People are also looking for solutions to the problem: variables - PHP $_POST values

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.