title: forms in Smarty
body: <p>I'm looking for some help creating a very simple form in a Smarty template but I'm not familiar with how to do this. </p>
  
  <p>The form calculates how many litres of a product a customer needs to cover X square metres. </p>
  
  <pre><code>&lt;form action="/calc.php" method="post"&gt;
  &lt;h4&gt;How much area would you like to cover?&lt;/h4&gt;
  &lt;input type="number" name="area" min="1"&gt;&amp;nbsp;m&lt;sup&gt;2&lt;/sup&gt;&lt;br&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>In the calc.php file I calculate the correct number of litres required. </p>
  
  <pre><code>$area = $_POST['area'];
  $coverage = $area/3.5;
  $litres = number_format($coverage/5,2);
  </code></pre>
  
  <p>could someone tell me how I pass the values from the php file back to the template?</p>
  
  <p>Is there a better way I should be doing this?</p>
  
  <p><strong>Update:</strong>
  template script is now: </p>
  
  <pre><code>&lt;form action="/calc.php" method="post"&gt;
  &lt;h4&gt;How much area would you like to cover?&lt;/h4&gt;
  &lt;input type="number" name="area" min="1"&gt;&amp;nbsp;m&lt;sup&gt;2&lt;/sup&gt;&lt;br&gt;
  &lt;input type="submit" style="margin-top:5px;"&gt;
  &lt;/form&gt;
  
  &lt;p&gt;You require {$litres_selected} Litres to cover an area of {$target_area} m&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;
  </code></pre>
  
  <p>php script is now: </p>
  
  <pre><code>&lt;?php
  
  $area = $_POST['area'];
  $coverage = $area/3.5;
  $litres = number_format($coverage/5,2);
  
  $smarty_object-&gt;assign(array('litres_selected' =&gt; $litres));
  $smarty_object-&gt;assign(array('target_area' =&gt; $area));
  
  ?&gt;
  </code></pre>