FP counter visibility

Posted on 2004-10-30
Last Modified: 2013-12-24
I run several web sites each with a FP hit counter. Idealy I would like each site to deposit the counter reading into a table from which a graph of hits vs day would be drawn. However this looks like a two month programming job. I will settle for

some ideas on how to make the counter readabel only by me.

E-mail me once a day, print hits in the background color, print hits on an unlisted page, or ?
Question by:aburr
    LVL 14

    Accepted Solution


    Here is a hit counter that i based on ASP and can write to the database,  you can view the counter or not.  How to install it? it is very easy.

    1- Create a new page in Frontpage
    2- Switch to HTML view
    3- Delete all the HTML code that you see
    4- Copy the following code into the HTML area which is blank now.  Copy the code as it is to Notepad then from notepad to the new blank html page that you have created in Frontpage.  Copy the code between the ---------------- lines.  

    ------------------------------------ The CODE Below This --------------------------------------

    '*     ASP 101 Sample Code -    *
    '*                                                     *
    '*   This code is made available as a service to our   *
    '*      visitors and is provided strictly for the      *
    '*               purpose of illustration.              *
    '*                                                     *
    '*      *
    '*                                                     *
    '* Please direct all inquiries to *

    <strong><%= RetrieveAndIncrementCount() %></strong>
    ' I placed this in a function so I wouldn't have to worry about
    ' any namespace collisions.  For example... if this was inline
    ' code and someone named a variable strSQL in a file this file
    ' gets included into you'd get an error.  This way you don't and
    ' there's no chance of the variables overwriting one another!
    Function RetrieveAndIncrementCount()
          ' From
          Const adOpenKeyset = 1
          Const adLockPessimistic = 2
          Const adCmdText = &H0001

          ' Local variables
          Dim strFilename
          Dim strSQL
          Dim rsCounter
          Dim iCount

          'Get filename and build SQL query
          strFilename = Request.ServerVariables("SCRIPT_NAME")
          strSQL = "SELECT page_name, hit_count FROM hit_count WHERE page_name='" & strFilename & "';"

          'Open our recordset
          Set rsCounter = Server.CreateObject("ADODB.Recordset")
          'Access version:
          rsCounter.Open strSQL, _
          "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("counter_db.mdb") & ";", _
          adOpenKeyset, adLockPessimistic, adCmdText
          ' SQL Server version:
          'rsCounter.Open strSQL, "Provider=SQLOLEDB;Data Source=;" _
          '      & "Initial Catalog=samples;User Id=samples;Password=password;" _
          '      & "Connect Timeout=15;Network Library=dbmssocn;", _
          '      adOpenKeyset, adLockPessimistic, adCmdText

          ' If we've got a record then we read the current value
          ' If we don't then we create one, set the filename, and start at 0
          If rsCounter.EOF Then

                iCount = 0

                rsCounter.Fields("page_name").Value = strFilename

                iCount = rsCounter.Fields("hit_count").Value
          End If

          ' Increment the count and update the DB
          rsCounter.Fields("hit_count").Value = iCount + 1

          ' Close our connection
          Set rsCounter = Nothing

          ' Return the count (pre-incrementation).
          RetrieveAndIncrementCount = iCount
    End Function

    --------------------------------- END of CODE ----------------------------------------

    5- Save the page as

    6- Create a database in Access to have the following:
    Database name: counter_db.mdb
    Database table name: hit_count
    Database table fields: page_name (text), hit_count(numeric)

    7- Import the database into your webfolder

    8- Make sure that the database has permission for Everyone and Internet Guest Account to write to the database.  Grant write permissions for Everyone and Internet guest account.

    9- Open the page that you want to place the hit counter on

    10- Copy the following line to the body of the page
    <!--#include file="counter_db_inc.asp"-->
    You can put this line in the body of each and every page you want to count  because the counter can count the hits for each page and in the page_name field,  the code will write the name of the page and the total hits.

    I modified the code to be used for Access database.

    Just create the database as I told you
    Save it
    Give it permissions
    Stick to the field names and page names I gave you

    Withing 10 minutes you will have your own counter.

    If you don't want to display the counter for users you can change this line which is at the top of the long code:

    <strong><%= RetrieveAndIncrementCount() %></strong>

    <strong><font color="#FFFFFF"><%= RetrieveAndIncrementCount() %></font></strong>

    This will make the font color white on a white page.  Change the color according to the background color of your page.

    This is a very nice counter,  it counts the hits of every page when it is visited.

    Please do not hesitate to ask.


    LVL 14

    Expert Comment

    You can use the database to create any chart you want.

    Also,  I gave you two essential fields in the database that get populated by the code,  you can add other fileds like time and date which will have a default value.  So,  you can tell whenever the page is visited.

    LVL 14

    Expert Comment

    You better try this counter,  it is easy to install and it will work fine.  I tried it myself.  It is very informative and you can use it for later statistics.

    LVL 26

    Author Comment

    answer looks good. I am half way down the page the bottom of which I will place the counter
    LVL 14

    Expert Comment

    Good luck

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Suggested Solutions

    Title # Comments Views Activity
    wordpress plugin to view newspaper 3 48
    Show/hide areas of web form 10 55
    Problem to event 1 493
    Dynamically highly text on a webpage 9 79
    When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
    Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
    The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be Log into your Hosting account. IPage will be used for demonstration : Locat…
    The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now