title: inserting data from a dynamic form into database
body: <p>I currently have a large form in which i need to to store the data in. the problem i have is the form isn't static and can become larger, for example the user could have 1++ addresses.</p>
  
  <p>The current table consists of id,form_id,value and field as columns. i can currently add the value from the form, however how do i create a unique identifier to know what to field is situated too. </p>
  
  <pre><code>  $surname = isset($_POST['surname'][0]) ? $_POST['surname'][0] : '';
    $address1 = isset($_POST['address1'][0]) ? $_POST['address1'][0] : '';
    $address2 = isset($_POST['address2'][0]) ? $_POST['address2'][0] : '';
    $address3 = isset($_POST['address3'][0]) ? $_POST['address3'][0] : '';
  </code></pre>
  
  <p>Then push these all into an array.</p>
  
  <pre><code>    foreach ($applicant as $value) {
          //statement to insert data
      $stmt = $pdo-&gt;prepare("INSERT INTO applicant1(form_id,value)VALUES(?,?)");
      $stmt-&gt;bindParam(1, $formid);
      $stmt-&gt;bindParam(2, $value);
      $stmt-&gt;execute();
  
      }
  </code></pre>
  
  <p>How can i get the name of the field it came from or is there a different approach?</p>