title: How to save data and print form at one click in php?
body: <p>I am working on invoice where I have to save form's data in database and at the same time it should be print. So, I have 3 pages: invoice.php, invoice_print.php and insert_data.php</p>
  
  <p>invoice_print.php is a html form that should be printed.</p>
  
  <p>Now, user will go to first invoice.php then he will fill details and either he will click on submit button to save data in db or else he will click on print button to print that invoice.</p>
  
  <p>Now, lets come to the second part: If user will select print button then  data will go to database first and then it will go to invoice_print.php with same data that he filled. </p>
  
  <p>How to do this? What logic should I use to save data and capture that data's id in button and then send that id on another page to display?</p>
  
  <p>invoice.php:</p>
  
  <pre><code>&lt;form id="demo-form2"  action="insert_data.php" method="post" data-parsley-validate class="form-horizontal form-label-left"&gt;
  &lt;div class="col-md-12 form-group"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;label class="control-label"&gt;Location&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;                                  
      &lt;input class="form-control" type="text" value="" name="designation"&gt;  
    &lt;/div&gt;                         
  &lt;/div&gt;        
  &lt;div class="col-md-12 form-group"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;label class="control-label"&gt;Address&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;                                  
      &lt;input class="form-control" type="text" value="" name="contact"&gt;  
    &lt;/div&gt;                         
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>invoice_print.php:</p>
  
  <pre><code>&lt;div class="col-md-12"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;h2&gt;DIGILIFE BIZCARE SOLUTIONS&lt;/h2&gt;
      &lt;p&gt;414, Vashi Infotech Park,Maharashtra&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;
      &lt;h2&gt;BILL OF SUPPLY&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-md-12"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;div class="col-md-12"&gt;
        &lt;div class="col-md-6"&gt;
          &lt;label&gt;GSTIN&lt;/label&gt;
          &lt;input type="text" name="gstin" value=""&gt;
          &lt;label&gt;Serial No &amp; Date of Invoice&lt;/label&gt;
          &lt;input type="text" name="serialNo"&gt;
        &lt;/div&gt;
        &lt;div class="col-md-6"&gt;
  
        &lt;/div&gt;        
      &lt;/div&gt;  
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;
      &lt;div class="col-md-12"&gt;
        &lt;div class="col-md-6"&gt;
          &lt;label&gt;Mode of Transport&lt;/label&gt;&lt;br&gt;
          &lt;label&gt;Vehicle No&lt;/label&gt;&lt;br&gt;
          &lt;label&gt;Date &amp; Time of Supply&lt;/label&gt;&lt;br&gt;
          &lt;label&gt;Place Of Supply&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="col-md-6s"&gt;
          &lt;input type="text" name=""&gt;
          &lt;input type="text" name=""&gt;
          &lt;input type="text" name=""&gt;
          &lt;input type="text" name=""&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="col-md-12 form-group"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;label class="control-label"&gt;Location&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;                                  
      &lt;input class="form-control" type="text" value="" name="designation"&gt;  
    &lt;/div&gt;                         
  &lt;/div&gt;        
  &lt;div class="col-md-12 form-group"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;label class="control-label"&gt;Address&lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="col-md-6"&gt;                                  
      &lt;input class="form-control" type="text" value="" name="contact"&gt;  
    &lt;/div&gt;                         
  &lt;/div&gt;
  </code></pre>