title: How do I log visitors from my HTML-page via PHP, with code separation?
body: <p>I have a website where I want to log visitor's IP-address, browser and date/time to a txt-file, with help of a PHP-script. I have a PHP-script now that does what I want, it logs this information, but only if I visit the PHP-file. So when I visit my HTML, nothing adds to the txt-file.</p>
  
  <p>I have tried both changing the HTML and the PHP, with for example require('home.html'); or $html = file_gets_contents("home.html"); in the PHP-file. But I'm very new to this language so I have no idea what I'm doing in this case.</p>
  
  <p>And also, this is a school assignment, and <strong>I can't use PHP-language in the HTML-file and vice versa</strong>, so it needs to be separated. But it's ok to change the HTML-file as well, or both. Hope anyone can help me!</p>
  
  <pre><code>$handle = fopen('visitors.txt', 'a');
  $data = "\nDate and time: " . date("Y.m.d, H:i:s") . "\nBrowser: " . $_SERVER['HTTP_USER_AGENT'] . "\nIP-address: " . $_SERVER['REMOTE_ADDR'] . "\n";
  fwrite($handle, $data);
  fclose($handle);
  echo file_get_contents('visitors.txt'); 
  </code></pre>
  
  <p>This is the code that works, but only for PHP visits, not visits for my website. (I know there is no code for that yet)</p>