Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    May 2006
    Location
    California
    Posts
    336
    Tokens
    0

    Default I need a code for a text based hit counter..

    I need a hit counter, but not an image, a regular text one. This may make me sound nooby, but I'm not exactly your every day HTML coder.

    Oh btw, this code can be in HTML or PHP

  2. #2
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Create a file called counter.php and put this code in it.
    PHP Code:
    <?php
    $file 
    "counter.txt"//URL of a text file to store the hits.

    $open fopen($file"r");
    $size filesize($file);
    $count fread($open$size);
    fclose($open);

    if (!isset(
    $_COOKIE['simplecount'])) {

        
    $open fopen($file"w");
        
    $count++;
        
    fwrite($open$count);
        
    fclose($open);

        
    setcookie("simplecount","Counted!",time()+66600000);

    }
    ?>
    In the same directory make counter.txt and put a zero in it. (In *nix CHMOD the text file to 646)

    To include it in a php enabled page.
    HTML Code:
    Hits: <?php include("counter.txt"); ?>
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  3. #3
    Join Date
    Aug 2005
    Location
    Location Location
    Posts
    1,730
    Tokens
    0

    Latest Awards:

    Default

    HTML Code:
    Hits: <?php include("counter.txt"); ?>
    [/QUOTE]

    Although it would be counter.php otherwise the code wouldnt work

  4. #4
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    i think it stores it in counter.txt so then it shows up i am not sure so dont count on it

  5. #5
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Quote Originally Posted by bondie.
    i think it stores it in counter.txt so then it shows up i am not sure so dont count on it
    Correct.

    counter.txt contains a number, when you include it, you only include a number, not other crap.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  6. #6
    Join Date
    Aug 2005
    Location
    Location Location
    Posts
    1,730
    Tokens
    0

    Latest Awards:

    Default

    But, if it directs the code towards counter.php and the file is called counter.txt that would conflict the script?

  7. #7
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Quote Originally Posted by Cumec
    But, if it directs the code towards counter.php and the file is called counter.txt that would conflict the script?
    No?

    How do you think it would?
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  8. #8
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    If they arent visisting counter.php then how will the Script know to add a number to the .txt file?

    JUst goto Thybag.co.uk - They have one wich works and is easy to follow lol while we get on with this "Discussion"
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  9. #9
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Quote Originally Posted by :.:Numark:.:
    If they arent visisting counter.php then how will the Script know to add a number to the .txt file?

    JUst goto Thybag.co.uk - They have one wich works and is easy to follow lol while we get on with this "Discussion"
    Ah, I getcha now. I forgot that part, and assumed it was obvious.

    PHP Code:
    <?php include("counter.php"); ?> // Anywhere on the page, to add to the counter.
    <?php include("counter.txt"); ?> // Wherever you want the amount to show.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •