Hello All,

I have been searching the net for anything pertaining to the following issue:

When a user enters their zip code, I need to verify that the area code (that they enter when they enter their phone number) is in the range of the zip code.

I know I can run into issues with cellphone numbers, but at this point I want to get this concept hashed out first.

My solution would be to have a database of zip codes and a corresponding database of area codes that corresponds to the zips. So if someone enters 10101 that the following area codes, 212, 718, 646, and 917 will show up.

Any suggestions or even examples? As I've said, I haven't found any on the net so far.

    There are several servers out there that you can use their API to get this information, but you'll have to pay for it.

    http://www.downloadzipcode.com/ lists all the zipcodes and their corresponding area codes. You could make a script that will crawl the site and insert the info you need into your database...

      Thanks for the prompt reply. But what is the technique for "crawling" a site? Any code examples?

        You will have to create a PHP script that will open up that page and pull the info that you want out. You'll need to know extensive PHP to know how to do this.

        If not, then you probably want to use a zipcode finder service that will find the info for you.

        USPS has one that you might want to look into.
        http://www.usps.com/webtools/address.htm

          I think one of the other options instead of crawling the site, is to use something like Black Widow and "rip" the site, create a DB of zips and corresponding emails.

          If I took this approach, I think I would need a way for the zips database to check the area codes database. Not sure how I would set this up. I'm thinking...

          Zip Code Entered: 10101 => Check Area Codes Database

          In the area codes database, should I have it structured so that zip codes are entered once and area codes are repeated? Or have the area codes entered once and zip codes repeated? I think the former instead of the latter? Thoughts...

            Write a Reply...