Hit counter site

Discussion in 'Web Programming' started by iJonny, Oct 3, 2008.

Hit counter site
  1. Unread #1 - Oct 3, 2008 at 3:48 PM
  2. iJonny
    Joined:
    Jul 25, 2007
    Posts:
    150
    Referrals:
    0
    Sythe Gold:
    0

    iJonny Active Member
    Banned

    Hit counter site

  3. Unread #2 - Oct 3, 2008 at 4:18 PM
  4. Merchant_in_the_dark
    Joined:
    Nov 27, 2007
    Posts:
    2,452
    Referrals:
    2
    Sythe Gold:
    0

    Merchant_in_the_dark Grand Master
    Banned

    Hit counter site

    You use a PHP-generated image in relation to a database that tracks the number of requests for the image from your server.

    It's pretty simple, but you'd also have to add the hitcounter generation pages if you want to make it an online service like the site you linked to.
     
  5. Unread #3 - Oct 3, 2008 at 8:11 PM
  6. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Hit counter site

    For just one simple counter I'd recommend using flat-file storage.
     
  7. Unread #4 - Oct 4, 2008 at 6:01 AM
  8. iJonny
    Joined:
    Jul 25, 2007
    Posts:
    150
    Referrals:
    0
    Sythe Gold:
    0

    iJonny Active Member
    Banned

    Hit counter site

    anyone have a simple html hit counter code?
     
  9. Unread #5 - Oct 4, 2008 at 7:59 AM
  10. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Hit counter site

    You can't use HTML for such a thing. HTML is just a markup-language used by the browser to display a static webpage.
     
  11. Unread #6 - Oct 22, 2008 at 7:21 PM
  12. FartKnocker
    Joined:
    Sep 3, 2007
    Posts:
    285
    Referrals:
    0
    Sythe Gold:
    5

    FartKnocker Forum Addict

    Hit counter site

    You can't use HTML.

    If you are new at web programming I suggest making a flat file counter with PHP.
     
  13. Unread #7 - Nov 9, 2008 at 4:08 PM
  14. lumentec_dark
    Joined:
    Nov 9, 2008
    Posts:
    52
    Referrals:
    0
    Sythe Gold:
    0

    lumentec_dark Member
    Banned

    Hit counter site

    Firefox crashed the first time I wrote this so I had to re-do it. :'(


    This short guide will allow you to add a counter to your pages. In order for this counter to work, you will need:

    - A professionally hosted website
    - MySQL

    If you lack either of those things (meaning you have a free hosted website, or something besides MySQL) then do not continue on with this guide, as it will be no help to you.

    Beyond that, you will be able to create your counter. The rest of this guide is useful for you only if you have:

    - CPanel
    - MySQL Administration in CPanel
    - PHPMyAdmin

    If you lack any of those things, contact me so I can write you a script which will take the place of this guide. If you don't know if you have these things, follow steps 1 and 4 to find out. If you cannot find any of the things in step 1 and 4, you do not meet the requirements.


    If you've met all the requirements so far, follow these steps to create your counter.





    Step 1: Locating your MySQL administration

    1. Open up CPanel.
    2. Locate the MySQL administration icon, which should look something like this:

    [​IMG]

    3. Click that icon.



    Step 2: Creating your database

    1. Locate this box:

    [​IMG]

    2. Type into the box "hits" and hit the "Create Database" button.

    3. When you create your database, a prefix may be added. To makes sure you know the real name of your database, look for it in the list here:

    [​IMG]

    4. Write down the name of your database.



    Step 3: Creating a user and adding it to the database

    1. Locate this box:

    [​IMG]

    2. Type in a username and password to use.

    3. Hit the "Create User" button.

    4. Locate the "Current Users" right above the boxes you typed the username and password into. Check the username, because a prefix may have been added.

    4. Write the username and password down.

    5. Locate the "Add users to your databases" section and configure it like this:

    [​IMG]

    6. Hit the "Add User to Database" button.



    Step 4: Locating PHPMyAdmin

    1. Find something that looks like this:

    [​IMG]

    2. Click that link.



    Step 5: Adding a Table

    1. Find your database on the left side and click it. It should look something like this:

    [​IMG]

    2. Find this and type in "hits" for the name and "2" for number of fields:

    [​IMG]

    3. Configure it like this:

    [​IMG]

    Bookmark 1

    4. Now go click this:

    [​IMG]

    5. Set it up like this and click the "Go" button in the right below the two fields you filled out, and make sure you have the "ignore" box checked like shown in the picture:

    [​IMG]

    END BOOKMARK



    Step 6: Adding the Counter

    1. Make your page a .php file instead of a .html or .html if you havn't done so already. (For some people this may require you to either re-upload the file as a .php or just to rename the file.)

    2. Add the following code anywhere inside the <body> tag where you want your counter number to appear replacing all instances of USERNAME, PASSWORD, DATABASE, and "home", if you plan on adding this to a different page besides the home page. :

    PHP:
    <?php
    $connection 
    mysql_connect("localhost","USERNAME","PASSWORD");

    mysql_select_db("DATABASE",$connection);

    $result mysql_query("SELECT * FROM hits WHERE page='home'") or
    die(
    mysql_error());

    $row mysql_fetch_array($result);

    $temp $row["number"]+1;

    mysql_query("UPDATE `DATABASE`.`hits` SET `number` = '$temp' WHERE CONVERT( `hits`.`page` USING utf8 ) = 'home' LIMIT 1");

    echo 
    $temp;
    ?>
    NOTE: If you'd like to add this to multiple pages, repeat Bookmark 1 and Step 6.



    THAT'S IT, now you've got a working page view counter!
    I hope this guide helped, it took me a quite a while to complete. :)
     
  15. Unread #8 - Dec 6, 2008 at 12:11 PM
  16. htaed
    Joined:
    Dec 19, 2005
    Posts:
    336
    Referrals:
    0
    Sythe Gold:
    0

    htaed Forum Addict
    Banned

    Hit counter site

    Really nice guide, thank you i may need this soon.
     
  17. Unread #9 - Dec 6, 2008 at 8:50 PM
  18. Barrows
    Joined:
    May 26, 2008
    Posts:
    627
    Referrals:
    1
    Sythe Gold:
    0

    Barrows Apprentice
    Banned

    Hit counter site

    I read a HTML tutorial.
     
< Javascript Tut | Need PHP/MySQL Ideas! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site