query($query); if($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $fileName = $row['filename']; $fileDownloadCount = $row['filedownloadcount']+1; $mysqli->query("UPDATE files SET filedownloadcount='$fileDownloadCount' WHERE fileuniqueid='$fileHash'"); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$fileName.'.zip"'); header('Content-Length: '.filesize("../securefiles/files/$fileHash.zip")); readfile("../securefiles/files/$fileHash.zip"); } } else { die("Invalid file"); } ?>