-----Original Message-----
From: Werner Otto [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 14, 2004 1:58 PM
To: Ash Singh; [EMAIL PROTECTED]
Subject: Re: Link

On Mon, 14 Jun 2004 13:46:04 +0200, Ash Singh <[EMAIL PROTECTED]>
wrote:

>
>
> -----Original Message-----
> From: Werner Otto [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 14, 2004 1:25 PM
> To: [EMAIL PROTECTED]
> Subject: Link
>
> Hi all,
>
> I have form that is made up of records retrieved from a database. The
> first column presents the information as a hyperlink. I need to be
able
> to
> keep a record on which one of the multiple hyperlinks where clicked.
> Based
> upon the selected link I need to pass the value to the next CGI and
> perform an sql query. ANY ideas?
>



Do you have a code example of how to pass the parameters to the next 
script?

This is a code snippet of the script which will be doing the processing
and then the redirection.

#!/usr/bin/perl

use CGI;
use DBI;
use DBD::ODBC;
use strict;

use CGI qw(param);
my $query = CGI::new();

my $link = param("link");

my $dbh = DBI->connect('dbi:ODBC:link', 'scott', 'tiger') or die print
"$DBI::errstr";

#if link 1 = google
if ($link == 1) {
    $ClickLink = "Google.com"
    $sth = $dbh->prepare(q{SELECT NumberOfClicks from ClickTable where
Link = ?});
    $sth->execute($ClickLink);
    my @row = $sth->fetchrow_array;

    if (!defined(@row)) {
       # increment the row element that has the numeric value of the
number
       # of clicks
       # $numclicks = $row[1];
       # $numclicks ++;
       $sth = $dbh->prepare(q{Update ClickTable SET NumberOfClicks = ?
where Link = ?});
       $sth->execute($numclicks,$ClickLink);
       $sth->finish();
       $dbh->disconnect;
       
       #do the redirection to the next script pass the parameters
throught the url
       print $query->redirect("nextCGI.pl?Link=$ClickLink");
    }
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to