title: Use open ended input field & use it to email one of three different email addresses based on input such as, zip code or state with PHP?
body: <p>I have a website that has a request a quote in a sidebar. They now want to sort the requests by input by state but the field is open. It accepts anything but blank currently. First, can anyone recommend a good place to gather all the zip codes of a state? I currently see there are 1365 zip codes in GA alone is there some API I can call or download? We are not even talking about cities. Is it even possible to do Zip, Cities and State? Would is just be recommended to force them to pick a state in a drop-down in addition to the input fields already in the sidebar?</p>
  
  <pre><code>$moving_from = strtolower($moving_from);
  if($moving_from === 'georgia' || $moving_from === 'ga') {
      $emailTo = 'georgia@example.com';
  }
  
  &lt;div class="main-input"&gt;
  &lt;label&gt;Moving From:&lt;/label&gt;
  &lt;input name="moving_from" type="text" value="&lt;?php echo $moving_from; ?&gt;" class=""/&gt;
  &lt;/div&gt;
  
  if(!isset($hasError)) {
  
      $subject = 'Submitted message from '.$f_name;
      $email2name = 'Website Lead';
  
      $body  = '&lt;table&gt;&lt;tbody&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Name:&lt;/td&gt;&lt;td&gt;'.$f_name.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Date Of Move:&lt;/td&gt;&lt;td&gt;'.$date_of_move.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Moving From:&lt;/td&gt;&lt;td&gt;'.$moving_from.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Moving To:&lt;/td&gt;&lt;td&gt;'.$moving_to.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Email:&lt;/td&gt;&lt;td&gt;'.$email.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Phone Number:&lt;/td&gt;&lt;td&gt;'.$phone.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Size Of Move:&lt;/td&gt;&lt;td&gt;'.$size_of_move.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;tr&gt;&lt;td&gt;Comments:&lt;/td&gt;&lt;td&gt;'.$comments.'&lt;/td&gt;&lt;/tr&gt;';
      $body .= '&lt;/tbody&gt;&lt;/table&gt;';
  
      $headers = "MIME-Version: 1.0" . "\r\n";
      $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
      $headers .= 'From: '.$email2name.' &lt;'.$email2.'&gt;' . "\r\n";
  
      mail($emailTo, $subject, $body, $headers);
  
      $emailSent = true;
  }
  </code></pre>