title: Can i post data from a select drop down to email using PHP?
body: <p>I'm currently building an html form with an action to a php-file.
  In the form i have some drop down menus in which the user needs to select one of the values. I need to retrieve that value and post it to an email. I know almost nothing of php and cannot find anywhere how this should be done. All i find online is doing this in combination with mysql or some database but i'm not working with databases here.</p>
  
  <p>Is this possible?</p>
  
  <p>thank you for the replies, but honestly i'm having too much problems getting it to work. I've been looking around for tutorials and demos but i just can't seem to get it to work properly. After so many hours i really need some help please</p>
  
  <p>my html is</p>
  
  <pre><code>&lt;form method="post" name="contact_form" action="contact.php"&gt;                       
  &lt;div class="form-div1"&gt;
                          &lt;label for="profile" class="label1"&gt;Select your profile&lt;/label&gt;
                          &lt;br&gt;
                          &lt;select id="user-type" class="selectlist"&gt;
                              &lt;option value="option1"&gt;I'm a first-time user&lt;/option&gt;
                              &lt;option value="option2"&gt;I would like to renew or upgrade&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-div2"&gt;
                          &lt;label for="SEN" class="label2"&gt;SEN&lt;/label&gt;
                          &lt;br&gt;
                          &lt;input type "text" name="input1" class="input1"&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-div3"&gt;
                          &lt;label for="email" class="label3"&gt;Email Address&lt;/label&gt;
                          &lt;br&gt;
                          &lt;input type "text" name="input2" class="input2"&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-div4"&gt;
                          &lt;label for="product_choice" class="label4" name="select_menu"&gt;Select your product&lt;/label&gt;
                          &lt;br&gt;
                          &lt;select id="product" class="selectlist"&gt;
                              &lt;option value="option1"&gt;JIRA&lt;/option&gt;
                              &lt;option value="option2"&gt;Confluence&lt;/option&gt;
                              &lt;option value="option3"&gt;JIRA Service Desk&lt;/option&gt;
                              &lt;option value="option15"&gt;Other&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-div42"&gt;
                          &lt;label for="product" class="label42"&gt;Specify your product&lt;/label&gt;
                          &lt;br&gt;
                          &lt;input type "text" name="input2" class="input2"&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-div5"&gt;
                          &lt;label for="license_choice" class="label5"&gt;Select your license&lt;/label&gt;
                          &lt;br&gt;
                           &lt;select id="select" class="selectlist"&gt;
                              &lt;option value="option1"&gt;25 users&lt;/option&gt;
                              &lt;option value="option2"&gt;50 users&lt;/option&gt;
                              &lt;option value="option3"&gt;100 users&lt;/option&gt;
  
                          &lt;/select&gt;
                      &lt;/div&gt;
  
                      &lt;div class="input_box_atlassian"&gt;
                          &lt;input type="submit" name="submit" value="Submit" class="submit-button-atl" /&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>my php reads like this</p>
  
  <pre><code>if(!isset($_POST['submit']))
  {
      echo "error; you need to submit the form!";
  }
  $profile = $_POST['profile'];
  $SEN = $_POST['SEN'];
  $email = $_POST['email'];
  $product_choice = $_POST['product_choice'];
  $product = $_POST['product'];
  $license_choice = $_POST['license_choice'];
  
  //Validate first
  if(empty($SEN)||empty($email)) 
  {
      echo "SEN and email are mandatory!";
      exit;
  }
  
  if(IsInjected($email))
  {
      echo "Bad email value!";
      exit;
  }
  
  $email_from = 'test@gmail.com';//&lt;== update the email address
  $email_subject = "Atlassian";
  $email_body = "You have received a new message from the user $email.\n".
      "Here is the message:\n $message".
  
  $to = "test@gmail.com";//&lt;== update the email address
  $headers = "From: $email_from \r\n";
  $headers .= "Reply-To: $email \r\n";
  //Send the email!
  mail($to,$email_subject,$email_body,$headers);
  //done. redirect to thank-you page.
  header('Location: thank-you.html');
  
  
  // Function to validate against any email injection attempts
  function IsInjected($str)
  {
    $injections = array('(\n+)',
                '(\r+)',
                '(\t+)',
                '(%0A+)',
                '(%0D+)',
                '(%08+)',
                '(%09+)'
                );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str))
      {
      return true;
    }
    else
      {
      return false;
    }
  }
  </code></pre>
  
  <p>I'm sure i'm doing a million things wrong but i have too little knowledge of programming to realize what it is. I do want to learn however but i just need help to get me on the right track.</p>
  
  <p>By the way, there is some javascript involved too, when a user selects one of the two options in the first select box, the input fields (div2 and div3) appear or disappear. I assume that wouldn't have to be a problem for php?</p>