title: PHP automatically refresh page if the content of a specific file has changed
body: <p>I'm trying to determine if the content of a specific file was changed and than automatically refresh a php page that displays a message.</p>
  
  <p>I want to make this a single php page that after loading, can check if "test.txt" was changed. </p>
  
  <p>If someone added or deleted data from the "test.txt", i need to automatically refresh the div in which the "message.php" is displayed.</p>
  
  <p>Basically I need to make "index.php" check if "test.txt" was changed. If yes than I have to automatically refresh the div in which the "message.php" is displayed or at least refresh the entire "index.php" 
  Here is what I am using:</p>
  
  <p>-a text file called "test.txt" in which text is added or deleted</p>
  
  <p>-a "check_md5.php" that check if the file was changed:</p>
  
  <pre><code>&lt;?php
  function file_was_changed($file_to_check,$interval_check_md5)
  {
      //intializez md5 variables to  0
      $valoare1_md5=$valoare2_md5=0;
  
      //detect first md5 value
      $valoare1_md5=(md5_file($file_to_check));
      echo '&lt;p&gt;FILE "'.$file_to_check.'" =&gt; MD5 1 ='.$valoare1_md5.'&lt;/p&gt;'.PHP_EOL;
  
      //wait for the given interval
      sleep($interval_check_md5);
  
      //detect second MD5 value
      $valoare2_md5=(md5_file($file_to_check));
      echo '&lt;p&gt;FILE "'.$file_to_check.'" =&gt; MD5 2 ='.$valoare2_md5.'&lt;/p&gt;'.PHP_EOL;
  
      //compare MD5 values and determine and set boolean accordingly
      if ($valoare1_md5==$valoare2_md5) 
      {
          return false;
          echo 'FILE WAS NOT CHANGED';
      } 
      else 
      {
          return true;
          echo 'FILE WAS CHANGED';
      };
  }
  
  ?&gt;
  
  &lt;?php
  
  $file_changed=(file_was_changed('test.txt',1));
  if ($file_changed==true)
  {
      echo 'FILE WAS MODIFIED';
  } 
  else 
  {
      echo 'FILE IS UNCHANGED';
  };
  
  ?&gt;  
  </code></pre>
  
  <p>-a "message.php" that displays the message "HELLO":</p>
  
  <pre><code>&lt;?php
      echo 'HELLO';
  ?&gt;
  </code></pre>
  
  <p>-a "index.php" that contains 2 divs in which "check_md5.php" and "message.php" are loaded:</p>
  
  <pre><code>&lt;html&gt;
  
  
  &lt;style&gt;
  .md5_status, .display {
    position: absolute;
    left: 0;
    right: 0;
  }
  
  .md5_status {
    top: 0;
    height: 15%;
    background-color: pink;  
   /* overflow:scroll; */
  }
  
  .display {
    bottom: 0;
    height: 85%;
    background-color: #ddd;    
  }
  &lt;/style&gt;
  
  &lt;body&gt;
      &lt;div id="links" class="md5_status"&gt;
      &lt;?php //include("verificare_md5.php"); ?&gt;
      &lt;?php include("check_md5.php"); ?&gt;
      &lt;/div&gt;
  
      &lt;div id="contents" class="display"&gt;  
      &lt;?php //include("extrage_date_din_xml.php"); ?&gt;
      &lt;?php include("message.php"); ?&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;html&gt; 
  </code></pre>
  
  <p>How can I make this? Thank you for taking the time to read my entire problem.  </p>