$ _ GET ['site'] is a value that comes directly from the browser URL, which means that the user can easily change this value to whatever he wants, you should check / misinform this value, all values ββare actually before sending to the database.
Something like this would be the beginning, it would still be possible to use more work, and there are many ways to do it, I would create a user-defined function / class to easily pass all variables through sitewide, which can just repeat things like this
$site = mysql_real_escape_string($_GET['site']); $start_date = mysql_real_escape_string($start_date); $end_date = mysql_real_escape_string($end_date); get_stats = mysql_query("SELECT * FROM visitors WHERE site='$site' AND date >= '$start_date' AND date <= '$end_date' ");
source share