Jump to content

visitors counter in php? [closed]


osamaboshi

Recommended Posts

I want to count user who open the page , I want to insert in mysql table when user open the page and I want to insert or upadet when close the page by click [x] or press alt+F4 but not onunload or onbeforeunload , cause this also call when refresh I want to call this alert when close onlyI can use a code which insert when open and not insert when refresh , but I couldnt solve insert or update when close the pagehere is my code:

<?session_start();if (!isset($_SESSION["visits"]))    $_SESSION["visits"] = 0;if ($_SESSION["visits"] > 0){echo 'visit='.$_SESSION["visits"];echo "You hit the refresh button!";}else{    mysql_query(        "INSERT INTO najd_visit( visit_userId, visit_staticId, visit_page,            visit_enterTime)VALUES ('$userId', '$Sid', '$title', '$date') ");    $_SESSION["visits"] = $_SESSION["visits"] + 1;echo 'visit='.$_SESSION["visits"];echo "This is my site";}?>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...