title: Contact Form PHP Email Script
body: <p>Hello I am having problem with the email script on my site.</p>
  
  <p>I used this files</p>
  
  <p><a href="https://jonbake.com/blog/bootstrap-3-contact-form-with-captcha/" rel="nofollow noreferrer">https://jonbake.com/blog/bootstrap-3-contact-form-with-captcha/</a></p>
  
  <p>but I add some fields. It is sending to my email but I'm not receiving all the data inputted on the fields.</p>
  
  <p>Here is my HTML Form</p>
  
  <pre><code>&lt;form role="form" id="feedbackForm"&gt;
            &lt;div class="form-group"&gt;
              &lt;input type="text" class="form-control" id="first_name" name="first_name" placeholder="First Name"&gt;
              &lt;span class="help-block" style="display: none;"&gt;Please enter your name.&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="form-group"&gt;
              &lt;input type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name"&gt;
              &lt;span class="help-block" style="display: none;"&gt;Please enter your name.&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="form-group"&gt;
              &lt;input type="email" class="form-control" id="email" name="email" placeholder="Email Address"&gt;
              &lt;span class="help-block" style="display: none;"&gt;Please enter a valid e-mail address.&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="form-group"&gt;
              &lt;input type="text" class="form-control" id="company_name" name="company_name" placeholder="Company"&gt;
              &lt;span class="help-block" style="display: none;"&gt;Please enter your name.&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="form-group"&gt;
              &lt;textarea rows="10" cols="100" class="form-control" id="message" name="message" placeholder="Message"&gt;&lt;/textarea&gt;
              &lt;span class="help-block" style="display: none;"&gt;Please enter a message.&lt;/span&gt;
            &lt;/div&gt;
            &lt;div class="form-group"&gt;
              &lt;label for="selectbasic"&gt;How did you hear about us?&lt;/label&gt;
                  &lt;select id="selectbasic" name="selectbasic" class="form-control"&gt;
                      &lt;option&gt;Select&lt;/option&gt;
                      &lt;option&gt;Search engine&lt;/option&gt;
                      &lt;option&gt;Microsoft DPE&lt;/option&gt;
                      &lt;option&gt;Microsoft event&lt;/option&gt;
                      &lt;option&gt;Social media&lt;/option&gt;
                      &lt;option&gt;Word of mouth&lt;/option&gt;
                      &lt;option&gt;Other&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
            &lt;img id="captcha" src="library/vender/securimage/securimage_show.php" alt="CAPTCHA Image" /&gt;
            &lt;a href="#" onclick="document.getElementById('captcha').src = 'library/vender/securimage/securimage_show.php?' + Math.random(); return false" class="btn btn-info btn-sm"&gt;Show a Different Image&lt;/a&gt;&lt;br/&gt;
            &lt;div class="form-group" style="margin-top: 10px;"&gt;
              &lt;input type="text" class="form-control" name="captcha_code" id="captcha_code" placeholder="For security, please enter the code displayed in the box." /&gt;
              &lt;span class="help-block" style="display: none;"&gt;Please enter the code displayed within the image.&lt;/span&gt;
            &lt;/div&gt;
  
            &lt;span class="help-block" style="display: none;"&gt;Please enter a the security code.&lt;/span&gt;
            &lt;button type="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style="display: block; margin-top: 10px;"&gt;Send Feedback&lt;/button&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>This is my PHP Script </p>
  
  <pre><code>&lt;?php
   //start a session -- needed for Securimage Captcha check
   session_start();
  
   //add you e-mail address here
   define("MY_EMAIL", "dummyemail@gmail.com");
  
  /**
   * Sets error header and json error message response.
   *
   * @param  String $messsage error message of response
   * @return void
   */
  function errorResponse ($messsage) {
  header('HTTP/1.1 500 Internal Server Error');
  die(json_encode(array('message' =&gt; $messsage)));
  }
  
  /**
   * Return a formatted message body of the form:
   * Name: &lt;name of submitter&gt;
   * Comment: &lt;message/comment submitted by user&gt;
   *
   * @param String $name     name of submitter
   * @param String $messsage message/comment submitted
   */
  function setMessageBody ($first_name, $last_name, $email, $message, $selectbasic) {
    $message_body = "Name: " . $first_name. $last_name. "\n\n";
    $message_body = "Email: " . $email."\n\n";
    $message_body = "Company Name: " . $company_name."\n\n";
    $message_body .= "Message:\n" . nl2br($message);
    $message_body .= "How did you hear about us?:" . $selectbasic."\n\n";
    return $message_body;
  }
  $first_name = $_POST['first_name'];
  $last_name = $_POST['last_name'];  
  $email = $_POST['email']; 
  $company_name = $_POST['company_name']; 
  $message = $_POST['message'];
  $selectbasic = $_POST['selectbasic'];
  
  header('Content-type: application/json');
  //do some simple validation. this should have been validated on the client-side also
  if (empty($email) || empty($message)) {
  errorResponse('Email or message is empty.');
  }
  
  //do Captcha check, make sure the submitter is not a robot:)...
  include_once './vender/securimage/securimage.php';
  $securimage = new Securimage();
  if (!$securimage-&gt;check($_POST['captcha_code'])) {
    errorResponse('Invalid Security Code');
  }
  
  //try to send the message
  if(mail(MY_EMAIL, "Feedback Form Results", setMessageBody($_POST["first_name"],         
  $_POST["last_name"], $_POST["email"], $_POST["selectbasic"], $message), "From:    
   $first_name, $last_name")) {
  echo json_encode(array('message' =&gt; 'Your message was successfully submitted.'));
  
    } else {
  header('HTTP/1.1 500 Internal Server Error');
  echo json_encode(array('message' =&gt; 'Unexpected error while attempting to send e-   
   mail.'));
   }
   ?&gt;
  </code></pre>
  
  <p>I don't know what's wrong but I need to capture all the data.</p>
  
  <p>Thanks for your help.</p>
  
  <p>This what I am getting after putting DOT before equal sign</p>
  
  <p><img src="https://i.stack.imgur.com/ZqiXQ.png" alt="enter image description here"></p>
  
  <p>New Code I'm using achieving the image above </p>
  
  <pre><code>&lt;?php
   //start a session -- needed for Securimage Captcha check
   session_start();
  
   //add you e-mail address here
   define("MY_EMAIL", "aareyes00@ymail.com");
  
   /**
   * Sets error header and json error message response.
   *
   * @param  String $messsage error message of response
   * @return void
   */
   function errorResponse ($messsage) {
   header('HTTP/1.1 500 Internal Server Error');
   die(json_encode(array('message' =&gt; $messsage)));
   }
  
  /**
   * Return a formatted message body of the form:
   * Name: &lt;name of submitter&gt;
   * Comment: &lt;message/comment submitted by user&gt;
   *
   * @param String $name     name of submitter
   * @param String $messsage message/comment submitted
   */
   function setMessageBody ($first_name, $last_name, $email, $company_name, $message,    
   $selectbasic) {
   $message_body .= "First Name: " . $first_name."\n\n";
   $message_body .= "Last Name: " . $last_name."\n\n";
   $message_body .= "Email: " . $email."\n\n";
   $message_body .= "Company Name:" . $company_name."\n\n";
   $message_body .= "Message:" . $message. "\n\n";
   $message_body .= "How did you hear about us?" . $selectbasic."\n\n";
   return $message_body;
   }
   $first_name = $_POST['first_name'];
   $last_name = $_POST['last_name'];  
   $email = $_POST['email']; 
   $company_name = $_POST['company_name']; 
   $message = $_POST['message'];
   $selectbasic = $_POST['selectbasic'];
  
   header('Content-type: application/json');
   //do some simple validation. this should have been validated on the client-side also
   if (empty($email) || empty($message)) {
   errorResponse('Email or message is empty.');
   }
   //do Captcha check, make sure the submitter is not a robot:)...
   include_once './vender/securimage/securimage.php';
   $securimage = new Securimage();
   if (!$securimage-&gt;check($_POST['captcha_code'])) {
   errorResponse('Invalid Security Code');
   }
  
   //try to send the message
   if(mail(MY_EMAIL, "Feedback Form Results", setMessageBody($_POST["first_name"],      
   $_POST["last_name"], $_POST["email"], $_POST["message"], $_POST["selectbasic"]), "From:    
   $first_name, $last_name")) {
   echo json_encode(array('message' =&gt; 'Your message was successfully submitted.'));
  
   } else {
   header('HTTP/1.1 500 Internal Server Error');
   echo json_encode(array('message' =&gt; 'Unexpected error while attempting to send e-   
   mail.'));
   }
   ?&gt;
  </code></pre>