title: How to get multi field form data in email body
body: <p>Complete newbie at PHP. help.</p>
  <p>I have written a large &quot;join the club&quot; form with 15 fields. the first 10 fields are required. last 5 are optional.</p>
  <p>Each field has ID and names. name=&quot;fname&quot; name=&quot;lname&quot;, for each field. (see below)___</p>
  <pre><code>&lt;!-- FORM STARTS HERE --&gt;
         
  &lt;form id=&quot;appliform&quot; name=&quot;applform&quot; method=&quot;post&quot;
        action=&quot;joinformscripts/test11.php&quot;
        enctype=&quot;text/plain&quot; &gt; 
  &lt;!-- php code still in progress. test memb.php ---&gt;
  
  &lt;label for=&quot;fname&quot;&gt;*First Name:&lt;/label&gt;&lt;br&gt;
       &lt;input type=&quot;text&quot; id=&quot;fname&quot; name=&quot;fname&quot; required&gt;&lt;br&gt;
        
  &lt;label for=&quot;lname&quot;&gt;*Last Name:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;lname&quot; name=&quot;lname&quot; required&gt;&lt;br&gt;
        
  &lt;label for=&quot;bizname&quot;&gt;*Business Name:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;bizname&quot; name=&quot;biz&quot; required&gt;&lt;br&gt;
        
  &lt;label for=&quot;bizadd&quot;&gt;*Business Mailing Address:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;bizadd&quot; name=&quot;bizadd&quot; required&gt; &lt;br&gt;
        
  &lt;label for=&quot;city&quot;&gt;*City:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;city&quot; name=&quot;city&quot; required&gt; &lt;br&gt;
        
  &lt;label for=&quot;state&quot;&gt;*State:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;state&quot; name=&quot;state&quot; required&gt; &lt;br&gt; 
        
  &lt;label for=&quot;zip&quot;&gt;Zip:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;zip&quot; name=&quot;zip&quot; required&gt; &lt;br&gt; 
        
   &lt;label for=&quot;bizphone&quot;&gt;*Business Phone:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;bizphone&quot; name=&quot;bizphone&quot; required&gt; &lt;br&gt;  
  
  &lt;label for=&quot;celphone&quot;&gt;Personal Phone:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;celphone&quot; name=&quot;celphone&quot;&gt; &lt;br&gt;
        
   &lt;label for=&quot;email&quot;&gt;*Email:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;email&quot; id=&quot;email&quot; name=&quot;email&quot; required&gt;&lt;br&gt;       
          
    
  &lt;hr&gt;
  
  &lt;h5&gt;Complete this information if you are also paying for an Associate Membership. &lt;/h5&gt;
           
  &lt;label for=&quot;fname&quot;&gt;Associate First Name:&lt;/label&gt;&lt;br&gt;
       &lt;input type=&quot;text&quot; id=&quot;afname&quot; name=&quot;afname&quot;&gt;&lt;br&gt;
        
  &lt;label for=&quot;lname&quot;&gt;Associate Last Name:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;alname&quot; name=&quot;alname&quot;&gt;&lt;br&gt;
      
  &lt;label for=&quot;bizphone&quot;&gt;Associate Business Phone:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;abizphone&quot; name=&quot;abizphone&quot; &gt; &lt;br&gt;  
  
  &lt;label for=&quot;celphone&quot;&gt;Associate Personal Phone:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; id=&quot;acelphone&quot; name=&quot;acelphone&quot;&gt; &lt;br&gt;
               
  &lt;label for=&quot;aemail&quot;&gt;Associate Email:&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;aemail&quot; id=&quot;aemail&quot; name=&quot;aemail&quot;&gt;&lt;br&gt; 
   
   &lt;hr&gt;    
    &lt;p&gt;test 11 @ 6.00p&lt;/p&gt;     
   &lt;!-- SEND BUTTON Submit using secure POST DATA button  
  when sent, opens remit payment page (in script)--&gt;
      
   &lt;input type=&quot;submit&quot; value=&quot;submit application&quot; &gt;&lt;br&gt;
     &lt;input type=&quot;reset&quot; value=&quot;clear form&quot;&gt;
    &lt;br&gt;
      &lt;br&gt;
      
      &lt;p&gt;Please remit payment on the next page.&lt;/p&gt;
      
  &lt;/form&gt;    &lt;!-- END MEMBERSHIP FORM with script action --&gt;  
  </code></pre>
  <h2>PHP script.</h2>
  
      
     
  <pre><code> &lt;?php
  // test 11
  // after submit, goes to Remit page for payment: yes. //
  // receive email with content in body:  NO   //
  
  $email_to = &quot;membership@xxxx.org&quot;;
  $email_from = &quot;membership@xxxx.org&quot;;
  
  
  $reply_to = $_POST[&quot;email&quot;];
  $headers = &quot;submitted by: .$mailfrom .$fname .$lname &quot;;
  
  
  
  $email_subject = &quot;New Member Application Form (phptest8) revised 6.00pm thursday dec 10&quot;;
  $headers = &quot;From: &quot; . $email_from . &quot;\n&quot;;
  $headers .= &quot;Reply-To: &quot; . $reply_to . &quot;\n&quot;;
  
  // NOT CAPTURING form variables.
      
   //This needs to send all the fields in the form on Join page.   
  if(isset($_POST['submit'])){
      $to = &quot;membership@efwba.org&quot;; // this is your Email address
      $from = $_POST['email']; // this is the sender's Email address
      $first_name = $_POST['fname'];
      $last_name = $_POST['lname'];
      $subject = &quot;Membership Form submission&quot;;
      
      $message = $first_name . &quot; &quot; . $last_name . &quot; 
      wrote the following:&quot; . &quot;\n\n&quot; . $_POST['message'];
      $message2 = &quot;my information &quot; . $fname . &quot;\n\n&quot; . $fname . $lname . $biz . $bizadd . $city . $state . $zip . $bizphone . $celphone . $email . $afname . $alname . $abizphone . $acelphone. $aemail.  $_POST['message'];
      }
  
     
      
  //Send the email. If the email is sent we will go to a REMIT PAYMENT page, if there is an error we will display a brief message.
  
      ini_set(&quot;sendmail_from&quot;, $email_from);
      $sent = mail($email_to, $email_subject, $email_body, $headers, $email_from);
      
      
      if ($sent)
      {
      header(&quot;Location:/joinformscripts/thank-you-for-joining.html&quot;);
          
      } else {
      echo &quot;There has been an error submitting your application. Please go back one page to verify all data has been entered correctly.&quot;;
      }
  
  
  
  // Function to validate against any email injection attempts
  function IsInjected($str)
  {
  ___
  </code></pre>
  <p>The host server -goDaddy, Cpanel- processes the php file and sends the email to the &quot;Membership@&quot;  account.
  After the form submits, it redirects to the Payment page, that part works!</p>
  <p><strong>However, I am NOT getting the field data inside the body of the email.</strong></p>
  <p>I see the starter line, but not what the applicant entered for contact info.</p>
  <p>I want the body/ data to be a simple format, so I can copy it all and drop into a spreadsheet (for club mail merge printing)
  It does not need to show the data labels.</p>
  <p>I want to see this data in the email body:
  &quot;I want to join your organization!&quot;
  fname lname
  biz
  bizaddress
  city state zip
  bizphone
  celphone
  bizemail</p>
  <p><strong><strong>QUESTION</strong>: what is the simplest method to capture each field into email_body?</strong></p>
  <p>Thank you!</p>