We help IT Professionals succeed at work.

Managing contact info

Medium Priority
199 Views
Last Modified: 2013-12-03
Hi...We have a contact form on our website that users fill out and submit to us.  Right now all that info is sent to one e-mail address.  We like to forward it to our closest retail location based on the users zip code.  Any ideas?  Thanks
Comment
Watch Question


I dont know if you are using a backend database, such as MySQL or MSSqlServer, but this is one example using databases:

Create an email address for each of your retail locations - you probably already have these.  Store these in a table such as:

   id   | distributor          |   email  
    1   | Palo Alto            |  sfbob@mydomain.com
    2   | Gump Valley       |  gvalley@mydomain.com


Create a table with ranges of zip codes as follows:

  start    | end      | distributor
  94040  | 96049  | 1
  94030  | 96039  | 1
  10000  | 10100  | 2

Note that two rows zipcode ranges are given to one distributor here, that's so that areas can overlap.

Then, if a customer gives you a zipcode, you can find the distributor email with:

   SELECT email FROM distributors WHERE id = (SELECT distributor FROM zipcodes WHERE start <= 94041 AND end >= 94041)


There is lots of different ways to achieve the same thing.  There are more efficient ways to implement the database tables and the SQL queries - it all depends on what you want to do, what you have available and how confident you are with the techniques.  You don't even need a database as long as you are willing to maintain a file in a format similar to:

  94030 96039 sfbob@mydomain.dom
  94040 96049 sfbob@mydomain.dom

...but the principle is basically the same - record the zipcode ranges that are assigned to each distributor, and then use some lookup mechanism to find the correct distributor

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
what language are you writing it in?
fridomCEO/Programmer
CERTIFIED EXPERT

Commented:
The code above is SQL and you can use it from within every programming languages.

Regards
Friedrich
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.