PDA

View Full Version : creating a text counter using cgi, (help)


Cloud Render
August 19th, 2002, 03:12
ok, I don't know any cgi scripting... although I know a few others (Vbasic, DBasic, html, javascrips, etc.. )

I want to know how to create a counter script, (counts hots on site), using CGI.

I know I'll need a cgi-bin, which I have, and 2 files. (I think)

counter.cgi and hits.txt

I think i know the CHMOD info on uploading too.

LOL literally, the only thing i need is the coding.


Thanks!

ammoQ
August 19th, 2002, 08:14
Well, CGI scripts can be written in many languages, althought many are written in Perl. Your ISP must allow the usage of CGI, otherwise it cannot work.

Nezzar
August 19th, 2002, 11:03
It has been a long time since I did something in Perl so don't expect working code :p:

require "hits.pl";#read the hits
$hits++;#increment by one

#write the data to file
open(COUNTER, "> hits.pl");
print COUNTER "\$hits = $hits;\n1;";
close(COUNTER);

As I said I don't know if this works. :emb:

If your host supports PHP you can use this as well:

@include("hits.php");//read the hits
$hits++;//increment the hits

$fh = fopen("hits.php", "w");
fputs($fh, "\$hits = $hits");
fclose($fh);