title: Returning a value from PHP to HTML
body: <p>EDIT: I have two files, one being HTML and the other a PHP Script. I'm making a simple calculator. In my HTML I have a simple form that contains 4 text boxes.
  First text box is to have a number.
  Second text box is to have the operation to be performed.
  Third text box is the second number.
  Fourth text box is the answer. 
  When user click on a calculate button, the action attribute redirects the HTML to a PHP script that performs all the algorithms. I wanted the PHP script to return the answer back to the fourth text box in my HTML form.</p>
  
  <p>How can I do this?</p>
  
  <p>Here is my code for the HTML.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta name = "description" content = "This is a home page"/&gt;
  &lt;meta name = "author" content = "William Salazar" /&gt;
  &lt;meta name = "keywords" content = "exercise for home page"/&gt;
  &lt;title&gt;Calculator&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Calculator&lt;/legend&gt;
          &lt;form action = "calculate.php" method = "post"&gt;
              Please type in two numbers and an operation (ex: 2 + 3)&lt;br/&gt;
              &lt;input type = "text" name = "fNum" size = "2"/&gt;
              &lt;input type = "text" name = "op" size = "2"/&gt;
              &lt;input type = "text" name = "sNum" size = "2"/&gt;=
          &lt;input type = "text" name = "ans" size = "2" readonly = "read" value = "&lt;?php echo htmlspecialchars($ans);?&gt;"/&gt;
              &lt;br/&gt;&lt;br/&gt;
              &lt;input type = "submit" value = "Calculate"/&gt;
          &lt;/form&gt;
      &lt;/fieldset&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the code for my PHP Script.</p>
  
  <pre><code>&lt;?php
  function addition()
  {
  
      $sum = (float)$_POST['fNum'] + (float)$_POST['sNum'];
      $_POST['ans'] = (string)$sum;   
      "&lt;form action ='CalculatorForm.php' method = 'post'&gt;"
      "&lt;/form&gt;"
  }
  
  
      switch($_POST['op'])
      {
          case '+':           
              addition();         
          break;
          case '-':
              subtraction();
          break;
          case '*':
              multiplication();
          break;
          case '/':
              division();     
          break;
          case '^':
              power();
          break;
          default:
          break;
      }
  
  ?&gt;
  </code></pre>
  
  <p>Of course I haven't finished with the other function. I am initially trying to test out my addition function and if that worked I was to copy and paste the code.</p>