I made a php script to counts the number of users have viewed my website’s pages. This is my code
<?php
require_once ('test.php');
$institute_id = 14;
$q = "INSERT INTO page_views2 ( institute_id, views) VALUES ( $institute_id, 1)
ON DUPLICATE KEY UPDATE views=views+1"
;
$r = mysqli_query ($dbc, $q);
?>
I added this to top of my webpages and this is working (views incrementing) properly when I open the pages. But my problem is When I refresh the page, page views is incrementing by 1. It is okey when it is open first time. But I want to avoid from this when someone is refreshing the page.
so can any body tell me how can I do this?
Use sessions?