title: Undefined variable: date on Line 81
body: <p>I am having trouble once again with the undefined variable errors within my PHP file. The error (date) is occurring on line 81 in the PHP file, and I am not sure exactly why this error will not subside. This program is supposed to allow a user to enter an IP address and current date in the 111.222.3.44 and mm/dd/yyyy formats. Could someone point out the issue here?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Displaying Errors&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
  &lt;?php
      $IP = '/^\d{3}\.\d{3}\.\d\.\d{2}$/';
      $number = '/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/';
  
      if (isset($_POST["IP"])) {$IP = $_POST["IP"];}
      if (isset($_POST["date"])) {$date = $_POST["date"];}
  
  if (preg_match('/^\d{3}\.\d{3}\.\d\.\d{2}$/' , $IP)) 
      { 
          print "Your IP address is good."; 
  
              if (preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $date))
                  { 
                      print "The date format is ok. Thank you for submitting your form&lt;br&gt;."; 
                  }
              else if ($date = " ")
      { 
  ?&gt;
  
          &lt;form method="GET" method="Lab 10.php" &gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;p&gt;
          IP Address
          &lt;input type="text" name="ip" value="&lt;?php echo $_REQUEST['IP']; ?&gt;"/&gt;&lt;br /&gt;
          &lt;p style="color:red;"&gt;Enter the date mm/dd/yy&lt;/p&gt;
          &lt;input type="text" name="date" value="
  
          &lt;?php echo $_REQUEST['date']; ?&gt;" /&gt;&lt;br /&gt;
  
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;input type="submit" value="Submit" /&gt;
          &lt;/form&gt;
          &lt;?php 
  
          print "&lt;font color=\"red\"&gt;The date is empty&lt;br&gt;&lt;/font&gt;";
          print "&lt;font color=\"red\"&gt;You need to resubmit the form&lt;/font&gt;";
  
  
      }
  
      else
      {
  
  
          ?&gt;&lt;form method="GET" method="Lab 10.php" &gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;p&gt;
          IP Address
          &lt;input type="text" name="IP" value="&lt;?php echo $_REQUEST['IP']; ?&gt;"/&gt;&lt;br /&gt;
          &lt;p style="color:red;"&gt;Enter the date mm/dd/yy&lt;/p&gt;
           &lt;input type="text" name="date" value="&lt;?php echo $_REQUEST['date']; ?&gt;" /&gt;&lt;br /&gt;
  
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;input type="submit" value="Submit" /&gt;
          &lt;/form&gt;
          &lt;?php
  
          print "&lt;font color=\"red\"&gt;The date format is incorrect&lt;br&gt;&lt;/font&gt;";
          print "&lt;font color=\"red\"&gt;You need to resubmit the form&lt;/font&gt;";
      }
  }
  
  else if ($IP = " ") //test if ip address is null
  {
      print "&lt;font color =\"red\"&gt;The IP Address is empty.&lt;/font&gt;&lt;br&gt;";
  
  
  
  
      if (preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $date))
          { 
              print "The date format is ok. Thank you for submitting your form&lt;br&gt;."; 
          }
             else if ($date = " ")
          { 
  
  
          ?&gt;&lt;form method="GET" method="Lab 10.php" &gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;p&gt;
          IP Address
          &lt;input type="text" name="ip" value="&lt;?php echo $_REQUEST['IP']; ?&gt;"/&gt;&lt;br /&gt;
          &lt;p style="color:red;"&gt;Enter the date mm/dd/yy&lt;/p&gt;
          &lt;input type="text" name="date" value="&lt;?php echo $_REQUEST['date']; ?&gt;" /&gt;&lt;br /&gt;
  
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;input type="submit" value="Submit" /&gt;
          &lt;/form&gt;
          &lt;?php 
          print "&lt;font color=\"red\"&gt;The date is empty&lt;br&gt;&lt;/font&gt;";
          print "&lt;font color=\"red\"&gt;You need to resubmit the form&lt;/font&gt;";
  
  
  
          }
  
      else
          {
  
  
          ?&gt;&lt;form method="GET" method="Lab 10.php" &gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;p&gt;
          IP Address
          &lt;input type="text" name="ip" value="&lt;?php echo $_REQUEST['IP']; ?&gt;"/&gt;&lt;br /&gt;
          &lt;p style="color:red;"&gt;Enter the date mm/dd/yy&lt;/p&gt;
          &lt;input type="text" name="date" value="&lt;?php echo $_REQUEST['date']; ?&gt;" /&gt;&lt;br /&gt;
  
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;input type="submit" value="Submit" /&gt;
          &lt;/form&gt;
          &lt;?php
  
          print "&lt;font color=\"red\"&gt;The date format is incorrect&lt;br&gt;&lt;/font&gt;";
          print "&lt;font color=\"red\"&gt;You need to resubmit the form&lt;/font&gt;";
          }
  
  }
  
  
      else //if IP is anything else but accepted
  { 
      print "&lt;font color=\"red\"&gt;Please enter a valid IP address.&lt;/font&gt;&lt;br&gt;"; 
  
  
  
      if (preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $date))
          { 
          print "The date format is ok. Thank you for submitting your form&lt;br&gt;."; 
  
  
          }
  
  
              else if ($date = " ")
          { 
          print "The date is empty&lt;br&gt;";
          print "You need to resubmit the form&lt;br&gt;";
  
          ?&gt;&lt;form method="GET" method="Lab 10.php" &gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;p&gt;
          IP Address
          &lt;input type="text" name="ip" value="&lt;?php echo $_REQUEST['IP']; ?&gt;"/&gt;&lt;br /&gt;
          &lt;p style="color:red;"&gt;Enter the date mm/dd/yy&lt;/p&gt;
          &lt;input type="text" name="date" value="&lt;?php echo $_REQUEST['date']; ?&gt;" /&gt;&lt;br /&gt;
  
  
          &lt;br /&gt;&lt;br /&gt;
  
           &lt;input type="submit" value="Submit" /&gt;
          &lt;/form&gt;
          &lt;?php 
          print "&lt;font color=\"red\"&gt;The date is empty&lt;br&gt;&lt;/font&gt;";
          print "&lt;font color=\"red\"&gt;You need to resubmit the form&lt;/font&gt;";
  
  
  
  
          }
  
      else
          {
          print "The date format is incorrect&lt;br&gt;";
          print "You need to resubmit the form&lt;br&gt;";
  
          ?&gt;&lt;form method="GET" method="Lab 10.php" &gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;p&gt;
          IP Address
           &lt;input type="text" name="ip" value="&lt;?php echo $_REQUEST['IP']; ?&gt;"/&gt;&lt;br /&gt;
          &lt;p style="color:red;"&gt;Enter the date mm/dd/yy&lt;/p&gt;
          &lt;input type="text" name="date" value="&lt;?php echo $_REQUEST['date']; ?&gt;" /&gt;&lt;br /&gt;
  
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;input type="submit" value="Submit" /&gt;
          &lt;/form&gt;
          &lt;?php
  print "&lt;font color=\"red\"&gt;The date format is incorrect&lt;br&gt;&lt;/font&gt;";
          print "&lt;font color=\"red\"&gt;You need to resubmit the form&lt;/font&gt;";
          }
  
  }
  
  
  
  
  
  
  
  ?&gt;
  </code></pre>
  
  <p>
  </p>