Managing contact info

Posted on 2006-03-28
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
Question by:Markv00
    LVL 11

    Accepted Solution


    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            |
        2   | Gump Valley       |

    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


    Expert Comment

    what language are you writing it in?
    LVL 24

    Expert Comment

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


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now