View Full Version : Finding location with PHP in e-mail
SpikeFinch
11-09-2011, 05:32 AM
Hi everyone,
I have a php script that a friend made for me a few years back that sends me a email from a web forum.
Right now, Every time I get a e-mail, I have to go look up the IP address to figure out how much the shipping is going to cost.
Is there a way to have the PHP do this for me?
It does not need to be 100% right 100% of the time, just most of the time would be nice.
I attached the code in a txt file..
Thanks
Spike
...why do you need the IP address to calculate shipping? wouldn't you need the _physical_ address?
just to be clear, the two do not always correlate. beyond that, what if they want their purchase shipped to someone else? what if they're on vacation, and they want it shipped to their house instead of their hotel?
you should be asking your customers to provide shipping information.
djr33
11-09-2011, 06:27 AM
It's a lazy way to get a guess about the address (just to calculate shipping costs, not to determine where to send it), but it's dangerous: if you tell someone they need to pay $5 then it turns out that they actually live in another country, you can't later tell them "sorry, it's actually $50". Relying on the IP is not a good idea.
But yes, if you want to find a location from an IP address, you can use a service that looks it up for you. One that works well with PHP is MaxMind's GeoIP. It's generally accurate at least about country and often about city, but it's not perfect.
Again, I don't recommend this, but it is technically possible.
SpikeFinch
11-09-2011, 06:44 PM
Your both correct.
Yes, before I build the Drum, I Email them and confirm all the info
This was not the final step. it is just the first step.
I was sending them the shipping info as kind of "your shipping will be about" thing..
But sounds like you guys are saying it would be better for me to just include in the forum a "please provide a shipping country" ?
Hmmm...
In general, yes. geolocation based on IP can be drastically wrong (usually, it's not too bad, like djr says, but it can be). And if you're basing a quote on it -even an "estimate"- people will get grumpy if you have to increase the amount.
djr33
11-10-2011, 01:07 AM
Honestly, it also might bother customers if you are able to guess where they live without them telling you. Maybe guessing the country would be helpful, but I imagine that many of your orders are from your own country, so that probably won't help too much. I don't think that waiting would hurt. Another way to approach this would be to give a list of sample shipping prices (a few major cities, maybe some other countries if you get a lot of international customers).
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.