title: How do i send data from an HTML form to a document?
body: <p>I have an HTML page which, after being filled up, needs to collect whatever data the user imputs and place it into a template document, which then needs to be converted into a pdf file and sent to the user to be printed. Does anyone have a tutorial for something similar to this? I have tried to find my way around with php and json files but i keep getting stuck at a certain point and i can't figure out an answer.</p>
  <p>Edit: this is an example i've tried, to send stuff into a json file, but all it does is open a webpage with half the code on it:</p>
  <pre><code>&lt;?php 
         
  if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
                     
      function get_data() { 
          $name = $_POST['name']; 
          $file_name='StudentsData'. '.json'; 
     
          if(file_exists(&quot;$file_name&quot;)) {  
              $current_data=file_get_contents(&quot;$file_name&quot;); 
              $array_data=json_decode($current_data, true); 
                                 
              $extra=array( 
                  'Name' =&gt; $_POST['name'], 
                  'Branch' =&gt; $_POST['branch'], 
                  'Year' =&gt; $_POST['year'], 
              ); 
              $array_data[]=$extra; 
              echo &quot;file exist&lt;br/&gt;&quot;; 
              return json_encode($array_data); 
          } 
          else { 
              $datae=array(); 
              $datae[]=array( 
                  'Name' =&gt; $_POST['name'], 
                  'Branch' =&gt; $_POST['branch'], 
                  'Year' =&gt; $_POST['year'], 
              ); 
              echo &quot;file not exist&lt;br/&gt;&quot;; 
              return json_encode($datae);    
          } 
      } 
    
      $file_name='StudentsData'. '.json'; 
        
      if(file_put_contents(&quot;$file_name&quot;, get_data())) { 
          echo 'success'; 
      }                 
      else { 
          echo 'There is some error';                 
      } 
  } 
         
  ?&gt; 
  </code></pre>
  <p>And for clarification, i need whatever fields are being filled, sent to a file, pasted into a template, and that template sent back to the user.</p>