title: Initialize variables that are not called from POST
body: <p>I am learning how to code PHP and I have two pages: rates.html and rates.php.  Our assignment has it so that we only need to run rates.php and will no longer need to use rates.html.  My way of going around this problem is as follows:</p>
  
  <pre><code>if (empty($_POST['txtInput'])){
      $inputCurrency = 0;
      $outputCurrency = 0;
      $txtInput = '';
  } else {
      $inputCurrency = $_POST['inputCurrency'];
      $outputCurrency = $_POST['outputCurrency'];
      $txtInput = $_POST['txtInput'];
  }
  </code></pre>
  
  <p>Input and output currencies are made in the form of a drop down list, and txtInput is the number that the user wants to convert.</p>
  
  <p>The only problem with this is that my page throws up an error message when a user submits a form without any input in the field.  The page loads the following code:</p>
  
  <pre><code>if ( empty($txtInput) ) {
      $error_message = 'Input is a required field.'; }
  else if ( !is_numeric($txtInput) )  {
      $error_message = 'Input must be a valid number.'; }
  else if ( $txtInput &lt;= 0 ) {
      $error_message = 'Input must be greater than zero.'; }
  else {
      $error_message = ''; }
  </code></pre>
  
  <p>Is there a way for the flag to not be thrown up on the pages first load?  Any help would be appreciated</p>