title: codeigniter build a calculator
body: <p>I am trying to build a calculator in PHP which will go into a Codeigniter controller. I have a form in html which gets the numbers. </p>
  
  <pre><code> &lt;!DOCTYPE html &gt;
  
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Calculator&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form action="calc.php" method="POST"&gt;
          &lt;input type="text" name="num1"&gt;
          &lt;input type="text" name="num2"&gt;
          &lt;input type="text" name="num3"&gt;
          &lt;input type="submit" value="Calculate"&gt;
  
          &lt;?php echo form_close();?&gt;
  
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have a formula that the calculator will operate on which I have tried to layout in the on the calc.php page.
          
  
  <pre><code>if (isset($_POST['value']))
  {
      $num1 = $_POST["num1"];
      $num2 = $_POST["num2"];
      $num3 = $_POST["num3"];
  }
  
  
  function calculate()
  { 
      $c = $num1/50;
  
      $b = $num2/12;
  
      $s = $num3/5;
  
      $p = $c + $b - $s;
  
      if($s &gt; 4)
      {
          $s= 4;
      }
  }
  
  
      echo $c." + ".$b." - ".$s = ";
      echo $p;
  </code></pre>
  
  <p>I do not think I am doing this quite right. all help greatly appreciated. </p>