Jump to content

visitors counter in php? [closed]


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...