Forum Moderators: coopster
i want to hide a button from people visiting the website from toronto.
i realize this is not foolproof, but it's not needed to be.
is there a special code i would use for something like
if ($remote_addr == "toronto"){
//don't show the button
}
i am not familiar with the many uses for remote host or addr, but i do know many ips use the customer's city in the string somewhere (i see it in my server logs).
if this won't work, are there any other suggestions?
many ips use the customer's city in the string somewhere (i see it in my server logs)
You can't depend on this data, though - a case in point, my own IP address always shows up as Toronto, but I don't even live in the same province.
There are several IP address databases out there. There is a good free one available from here:
[ip-to-country.webhosting.info...]
However it is difficult to filter for a particular city without blocking a much larger region.
using any database mechanisms is overkill and could slow the page down significantly
Just for discussion, ip2location looks pretty good, and their city/state database is only $200/year, but when I did 5 queries, it only had city/state for 2 of them (though those two were very accurate).