Is there a way to make your own hit counter?

thawolfman

Lifer
Dec 9, 2001
11,107
0
76
How hard is that to do without having to have a 3rd party put one at the bottom of your page for you?

Or is it just easier to sign up for one?

-Ben-
 

atom

Diamond Member
Oct 18, 1999
4,722
1
0
It's not hard at all to make your own script. But if you don't know how, there are literally millions of hit counter scripts in dozens of different languages all over the web.
 

thawolfman

Lifer
Dec 9, 2001
11,107
0
76
I just signed up for some 3rd party stuff @ bravenet - site's in the sig and I wouldn't know where to begin to look for something...well aside from google that is :p
 

minendo

Elite Member
Aug 31, 2001
35,560
22
81
<?php
$fp = fopen("stats.txt","a+");
$count = fread($fp, 10);
$count = $count+1;
echo "You are Visitor No. ", $count ;
fclose($fp);
$fp = fopen("stats.txt","w+");
fwrite($fp, $count, 10);
fclose($fp);
?>
 

Anubis

No Lifer
Aug 31, 2001
78,712
427
126
tbqhwy.com
Originally posted by: minendo
<?php
$fp = fopen("stats.txt","a+");
$count = fread($fp, 10);
$count = $count+1;
echo "You are Visitor No. ", $count ;
fclose($fp);
$fp = fopen("stats.txt","w+");
fwrite($fp, $count, 10);
fclose($fp);
?>

what do you do with that?
just copy it into your webpages HTML file?
 

minendo

Elite Member
Aug 31, 2001
35,560
22
81
Originally posted by: Anubis
Originally posted by: minendo
<?php
$fp = fopen("stats.txt","a+");
$count = fread($fp, 10);
$count = $count+1;
echo "You are Visitor No. ", $count ;
fclose($fp);
$fp = fopen("stats.txt","w+");
fwrite($fp, $count, 10);
fclose($fp);
?>

what do you do with that?
just copy it into your webpages HTML file?
Place it into the code of the page (the page has to be php). Also, create a blank txt document named stats.txt and place it in the same directory as the page the code is located on. Set the permissions on stats.txt to 777.

Sample Page

 

Anubis

No Lifer
Aug 31, 2001
78,712
427
126
tbqhwy.com
Originally posted by: minendo
Originally posted by: Anubis
Originally posted by: minendo
<?php
$fp = fopen("stats.txt","a+");
$count = fread($fp, 10);
$count = $count+1;
echo "You are Visitor No. ", $count ;
fclose($fp);
$fp = fopen("stats.txt","w+");
fwrite($fp, $count, 10);
fclose($fp);
?>

what do you do with that?
just copy it into your webpages HTML file?
Place it into the code of the page (the page has to be php). Also, create a blank txt document named stats.txt and place it in the same directory as the page the code is located on. Set the permissions on stats.txt to 777.

well that was like greek to me, i think ill pass, im a compleat n00b at this, my site which is in my sig, it took me 2 days to do just that useing dreamweaver
 

sillymofo

Banned
Aug 11, 2003
5,817
2
0
Originally posted by: Anubis
well that was like greek to me, i think ill pass, im a compleat n00b at this, my site which is in my sig, it took me 2 days to do just that useing dreamweaver
Man, u should be able to put that up in 10 mins with note pad...... :p
 

Anubis

No Lifer
Aug 31, 2001
78,712
427
126
tbqhwy.com
Originally posted by: cr4zymofo
Originally posted by: Anubis
well that was like greek to me, i think ill pass, im a compleat n00b at this, my site which is in my sig, it took me 2 days to do just that useing dreamweaver
Man, u should be able to put that up in 10 mins with note pad...... :p

i understand greman better then HTML, i suck at the webpages
 

RossMAN

Grand Nagus
Feb 24, 2000
79,006
430
136
Originally posted by: Anubis
Originally posted by: minendo
Originally posted by: Anubis
Originally posted by: minendo
<?php
$fp = fopen("stats.txt","a+");
$count = fread($fp, 10);
$count = $count+1;
echo "You are Visitor No. ", $count ;
fclose($fp);
$fp = fopen("stats.txt","w+");
fwrite($fp, $count, 10);
fclose($fp);
?>

what do you do with that?
just copy it into your webpages HTML file?
Place it into the code of the page (the page has to be php). Also, create a blank txt document named stats.txt and place it in the same directory as the page the code is located on. Set the permissions on stats.txt to 777.

well that was like greek to me, i think ill pass, im a compleat n00b at this, my site which is in my sig, it took me 2 days to do just that useing dreamweaver

I'm a n00b at this also but I do understand creating a blank stats.txt document (Notepad) and CHMOD it to 777.

But I'm still confused on how/where to put that code? Would I use phpmyadmin or something like that?
 

rh71

No Lifer
Aug 28, 2001
52,844
1,049
126
*oops I read rossman wrong* ... you should be putting that code on any page you want the counter to increment/show.

That's the easiest way to do it... write to a text file. Others keep a database but that involves more processing power. You can also use session variables to keep people from constantly refreshing to increase the count repeatedly.

I can't code PHP from scratch too well, but man, you can do the same thing with Cold Fusion in 3 lines. ;) It's too bad it ain't free.
 

johnjbruin

Diamond Member
Jul 17, 2001
4,401
1
0
HTML is easy.
In the thread skoorb had earlier... everybody doing anything related to computers should know it.
 

ISAslot

Platinum Member
Jan 22, 2001
2,891
108
106
Here's mine in ASP. It only counts one IP hit per session into a database.


Option Explicit
'On Error Resume Next

'Declare Vars
Dim dec, ip, page, table

'Set Vars
page = "iab_default"
table = "calendar"
dec = Session(page)
ip = Request.ServerVariables("REMOTE_ADDR")

'If vars ok then count hit
If dec = "" Then
If ip = "" Then ip = "Unknown"
Dim rs, con
Set con = Server.CreateObject("ADODB.Connection")
con.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=xxxx"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT IP, LastHit, " & page & " FROM " & table & " WHERE (IP = '" & ip & "')", con, 0, 3
If Not rs.EOF Then
rs("LastHit") = Now()
rs(page) = rs(page) + 1
rs.Update
Else
rs.Close
rs.Source = "SELECT TOP 1 * FROM " & table
rs.Open()
rs.AddNew
rs("IP") = ip
rs(page) = 1
rs.Update
End If
rs.Close: Set rs = Nothing
con.Close: Set con = Nothing
Session(page) = "Yes"
End If
 

minendo

Elite Member
Aug 31, 2001
35,560
22
81
Originally posted by: RossMAN
Originally posted by: Anubis
Originally posted by: minendo
Originally posted by: Anubis
Originally posted by: minendo
<?php
$fp = fopen("stats.txt","a+");
$count = fread($fp, 10);
$count = $count+1;
echo "You are Visitor No. ", $count ;
fclose($fp);
$fp = fopen("stats.txt","w+");
fwrite($fp, $count, 10);
fclose($fp);
?>

what do you do with that?
just copy it into your webpages HTML file?
Place it into the code of the page (the page has to be php). Also, create a blank txt document named stats.txt and place it in the same directory as the page the code is located on. Set the permissions on stats.txt to 777.

well that was like greek to me, i think ill pass, im a compleat n00b at this, my site which is in my sig, it took me 2 days to do just that useing dreamweaver

I'm a n00b at this also but I do understand creating a blank stats.txt document (Notepad) and CHMOD it to 777.

But I'm still confused on how/where to put that code? Would I use phpmyadmin or something like that?
Just place it in the body of the php page you want it to display on.

 

RossMAN

Grand Nagus
Feb 24, 2000
79,006
430
136
I am still confused/lost.

Maybe minendo can hold my hand and walk me through it ;)
 

RossMAN

Grand Nagus
Feb 24, 2000
79,006
430
136
Originally posted by: thawolfman
Originally posted by: RossMAN
I am still confused/lost.

Maybe minendo can hold my hand and walk me through it ;)

Or he can bitch slap you and leave you in the dust! :Q

If I'm the bitch then he must be the pimp ;)
 

minendo

Elite Member
Aug 31, 2001
35,560
22
81
Originally posted by: RossMAN
Originally posted by: thawolfman
Originally posted by: RossMAN
I am still confused/lost.

Maybe minendo can hold my hand and walk me through it ;)

Or he can bitch slap you and leave you in the dust! :Q

If I'm the bitch then he must be the pimp ;)
I'm Rick James beeyatch.

 

rh71

No Lifer
Aug 28, 2001
52,844
1,049
126
Rossman can figure out how to piece deals and pricematch but he can't figure out how to put code on any given page. HMMMM. ;)
 

arcenite

Lifer
Dec 9, 2001
10,660
7
81
Originally posted by: rh71
Rossman can figure out how to piece deals and pricematch but he can't figure out how to put code on any given page. HMMMM. ;)

I wish rossman would pick one damn avatar
 

minendo

Elite Member
Aug 31, 2001
35,560
22
81
Originally posted by: aRCeNiTe
Originally posted by: rh71
Rossman can figure out how to piece deals and pricematch but he can't figure out how to put code on any given page. HMMMM. ;)

I wish rossman would pick one damn avatar
Turn off avatars. Problem solved.

 

RossMAN

Grand Nagus
Feb 24, 2000
79,006
430
136
Originally posted by: minendo
Originally posted by: aRCeNiTe
Originally posted by: rh71
Rossman can figure out how to piece deals and pricematch but he can't figure out how to put code on any given page. HMMMM. ;)

I wish rossman would pick one damn avatar
Turn off avatars. Problem solved.

I can just imagine the uproar that would ensue.