Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting clicks

Status
Not open for further replies.

missippi

IS-IT--Management
Feb 8, 2001
42
US
Hi,

I am trying to search a file and increase a counter number in the file when a url is clicked on a page. The file is set up like this

url | title | description | 0

The 0 being the number I want to change when someone clicks on the url. I am passing the file name and url.

Thanks!

#!/usr/bin/perl -w

use CGI;
use strict qw:)standard);

my $r = new CGI; # make a new CGI object

my $filename = $r->param('file');
my $readline;
my @linearray;
my $arraylen;
my $find;
my @data;
my $fileurl = $r->param('url');
my $i;

$i = 0;

print "location: $fileurl
Content-type: text/html \n\n";






#$filename = $r->param('file');
#$fileurl = $r->param('url');

redirect("$fileurl");

open (LINKS, "$file");

while ($readline = <LINKS>) {
chop($readline);
@data = split(/\|/,$readline);
$find = index($data[0], $fileurl);
if($find == -1) {

$data[3] = $data[3] + 1;

}
$linearray[$i] = $data[0] . '|' . $data[1] . '|' . $data[2] . '|' . $data[3];
print $linearray[$i];
print $r->br;
$i = $i + 1;
}

close(LINKS);

open (LINKS, &quot;>>$file&quot;);

$arraylen = @linearray.&quot;&quot;;
my $j;

for ($j = 0; $j < $arraylen; ++$j) {
print LINKS &quot;$linearray[$j]\n&quot;;
}

close(LINKS);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top