Edit Article

  • 58,609 views
  • 20 Editors

  • Edited

A hit counter or a page counter counts the number of people that visit your page. If you have created a new website, you might be interested in how many people are visiting.

Ad

Steps

  1. Make a PHP Hit Counter Step 1 Version 2.jpg
    1
    Open a new PHP file and call it counter.php
    Ad
  2. Make a PHP Hit Counter Step 2 Version 2.jpg
    2
    Enter the following PHP code into the file:
  3. Make a PHP Hit Counter Step 3 Version 2.jpg
    3
    Save the file in the main directory of your website.
  4. Make a PHP Hit Counter Step 4 Version 2.jpg
    4
    Add the following to the bottom of any page you wish to include the counter on:
    Ad


We could really use your help!

Can you tell us about
computers?
Yes I can
computers
how to dock a laptop
Can you tell us about
estate planning?
Yes I can
estate planning
how to set up an Estate
Can you tell us about
business operations?
Yes I can
business operations
how to retain customers
Can you tell us about
small business?
Yes I can
small business
how to set up a store
Thanks for helping! Please tell us everything you know about
...
Tell us everything you know here. Remember, more detail is better.
Tips
Provide Details.
Please be as detailed as possible in your explanation. Don't worry about formatting! We'll take care of it. For example:
Don't say: Eat more fats.
Do say: Add fats with some nutritional value to the foods you already eat. Try olive oil, butter, avocado, and mayonnaise.

Tips

  • This code explained: In this code you made a session called "views", this is where your session data is stored. When someone opens their web browser or refreshes it, the page number will be increased by one, this will be useful if you want to see if someone is re-visiting the website. Then you use the "echo" function to print it all onto the page.

Things You'll Need

  • A bit of programing knowledge if you don't know any PHP or HTML - this is not necessary, but it will help you to understand this tutorial better.

Article Info

Categories: Creating and Enhancing a Website | PHP

Recent edits by: Adelaide, Abhi, Chris

In other languages:

Español: Cómo hacer un contador de visitas PHP, Italiano: Come Creare un Contatore di Visualizzazioni in PHP, Português: Como Criar um Contador de Visitas em PHP, Русский: написать счетчик посещений сайта на РНР

Thanks to all authors for creating a page that has been read 58,609 times.

Did this article help you?
Yes No

Become
an Author!

Write an Article