treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Contact form - different mail functions depending on what option you choose?

  • I have a client site that I am working on they have 5 locations for there business. They want a corporate site for all locations, yet a contact form with a select drop-down at the top and depending on which location is selected, the data will be emailed to the specific locations email. How does this work? I don't think this the best usable type of form, but the client is dead set on it.

    I'm pretty sure an if statement through php that said if location1 = 1 {email here}, elseif location2 = 1 {email here}, etc? Is that right?

    I'm not the greatest with php so...

    Also I found this on another site, but it is directing to a new page:



    <select onchange="jQuery('#locations_search').submit();" name="location-page-id">
    <option value="0">Select your location</option>
    <option value="1">Alabama</option>
    <option value="2">Arkansas</option>
    <option value="3">Arizona</option>
    <option value="4">California</option>
    </select>

  • A switch would be quicker than an if :) e.g.


    switch ($_POST['location-page-id']) {
    case '1':
    $strEmail = 'something@email.com';
    break;

    case '2':
    $strEmail = 'me@email.com';
    break;

    etc...
    }