So I wanted to make something like a counter for visits for every page AND directory. The purpose was that of a security perspective but so far I've only managed to think of this:
<?php
include('connect.php');
$date = date("d.m.Y H:i:s",time());
$url = $_SERVER['REQUEST_URI'];
$ip = $_SERVER['REMOTE_ADDR'];
$query = "INSERT INTO `visits` VALUES ('','$date','$url','$ip')";
mysql_query($query);
?>
Problem is that in order for this to work I need to include this snippet in each file which isn't exactly what I need since, for example, I can't include it in any of my files in the /js/
folder. How can I make use of something like this and log each visit on each page individually?