Hello, I want to do the following for my site: - I need a script that checks the validity of an postal code inputted in 1 or 2 text fields. this is to check Canadian Postal codes in the form of X1X 1X1. I'm NOT looking to for a script that checks the format of the inputted value...per example if a user puts in XX1 1X1 HE/SHE gets an invalid entry..<---I don't want that. My thinking is to have a script that checks the validity of a postal code as inputed...per example a user types X1X 1X1 and the postal code is looked for in a database for validity. One solution is to have a database with all the postal codes/zip codes(later on); but they're millions of them. a second solution is to have a remote script tapping into a database such UPS to check for postal code validity. Do any of you know if this is doable? ever seen in before? what else can I do to make this work? All help is kindly appreciated.
I'm not a PHP expert, but I think you could do it with curl function to go check UPS's site. Other than that, for like $200 I'm sure someone will make you a database of all US and Canada Postal and Zip codes.
I'd suggest a local database of postal codes. That way you're not dependant on a secondary source for that information. If it is a fairly reliable source though, such as the USPS, why not go for it.
You need to also budget for updates to the db - I dont know about canada but the UK postcode database is updated every 3 months. Secondly you need to work out what to do with people who's postcode is not currently in the version of the db you have. When I moved into my current home it was a new build and so had a new postcode therefore websites that validate against a db of postcodes rejected any orders etc from me because my postcode wasnt in the db but those that only check format rather than existance accepted my orders. Do you want to be turning business away or is it better to lose those customers on the assurance that those you do get have valid postcodes?
yeah you're right. I have found a company that does demographics adn postal/zip codes, I'm pretty sure that for $500/year, they'd update it automatically...or I can talk to a person at the nation postal office. thanks for the reply.
Never change??? Would be very surprised that the whole country has postcode so if someone builds a new village/ town the postcode is already there. In the UK your own postcode will almost never change - there have been a few exceptions, namely London where they had to create more for central London a few years back - however new streets/ villages/ towns are given new postcodes
postal codes don't change, It's new ones that are added every 4 months into the system. I found a data company where I can use their database (updated quarterly) for my needs.