#!/usr/bin/perl -wT # track_banner.cgi use strict; use DBI; use CGI qw(:standard); use POSIX; my $dbname = 'book'; my $dbhost = 'localhost'; my $dsn = "DBI:mysql:database=$dbname;host=$dbhost"; my $dbh=DBI->connect($dsn,"user","password"); if (!defined($dbh)) { print header; print "\nerror: There is a problem connecting to the MySQL database:\n"; print DBI->errmsg; print "-" x 25; exit; } my $url = param('url'); my $image = param('img'); my $time = strftime("%Y-%m-%d %I:%M:%S", localtime); my $query = qq(update image_tracker set CLICKS=CLICKS+1, LAST_CLICK='$time' where IMAGE='$image' and URL='$url'); my $sth = $dbh->prepare($query); $sth->execute; $dbh->disconnect; print redirect($url);