Hi guys,
I have a small problem with my Perl-CGI script, and I would appreciate if anyone can help me out with this. I'm trying to get this done in two stages. 1st to get a bunch of info from the web and display it (which is working fine), but the 2nd part is, I want to add some of these info into my MySQL table after viewing them (I don't know how to do in Perl). Right now the script immediately adds values to the MySQL table, before I even click on submit button.
Thanks alot in advance.
Following is the script that I'm trying to write.
[code=perl]
#!/usr/bin/perl -w
use strict;
use CGI;
use LWP::Simple;
use Bio::DB::SwissP rot;
use DBI;
my $cgi = new CGI;
print $cgi->header() .
$cgi->start_html( -title => 'Results',
-bgcolor => '#6699CC').
# HTML table starts...
print '<TABLE border="1" cellspacing="0" cellpadding="3" width="80%">' . "\n";
......
print "<tr><th width='15%'>Ent ry Name</th><td>" . $id . "</td></tr>\n";
print "<tr><th>Access ion</th><td>" . $accession . "</td></tr>\n";
print "<tr><th>Protei n Name</th><td>" . $sequence . "</td></tr>\n";
......
print "<tr><td><I NPUT type=\"reset\" name=\"cancel\" value=\"Cancel\ "></td>"; print "<td><INPUT type=\"submit\" name=\"update\" value=\"Update\ " onsubmit=\"???\ "></td></tr>";
....
my $dbh = DBI->connect ("DBI:mysql:dat abase:xxx.xxx.x xx.xxx","root", "password") or die "Error: $DBI::errstr\n" ;
my $sql = "INSERT INTO table (a, b, c) VALUES ('$accession', '$sequence', '$id')";
my $in = $dbh->prepare($sql );
$in->execute;
[/code]
I have a small problem with my Perl-CGI script, and I would appreciate if anyone can help me out with this. I'm trying to get this done in two stages. 1st to get a bunch of info from the web and display it (which is working fine), but the 2nd part is, I want to add some of these info into my MySQL table after viewing them (I don't know how to do in Perl). Right now the script immediately adds values to the MySQL table, before I even click on submit button.
Thanks alot in advance.
Following is the script that I'm trying to write.
[code=perl]
#!/usr/bin/perl -w
use strict;
use CGI;
use LWP::Simple;
use Bio::DB::SwissP rot;
use DBI;
my $cgi = new CGI;
print $cgi->header() .
$cgi->start_html( -title => 'Results',
-bgcolor => '#6699CC').
# HTML table starts...
print '<TABLE border="1" cellspacing="0" cellpadding="3" width="80%">' . "\n";
......
print "<tr><th width='15%'>Ent ry Name</th><td>" . $id . "</td></tr>\n";
print "<tr><th>Access ion</th><td>" . $accession . "</td></tr>\n";
print "<tr><th>Protei n Name</th><td>" . $sequence . "</td></tr>\n";
......
print "<tr><td><I NPUT type=\"reset\" name=\"cancel\" value=\"Cancel\ "></td>"; print "<td><INPUT type=\"submit\" name=\"update\" value=\"Update\ " onsubmit=\"???\ "></td></tr>";
....
my $dbh = DBI->connect ("DBI:mysql:dat abase:xxx.xxx.x xx.xxx","root", "password") or die "Error: $DBI::errstr\n" ;
my $sql = "INSERT INTO table (a, b, c) VALUES ('$accession', '$sequence', '$id')";
my $in = $dbh->prepare($sql );
$in->execute;
[/code]
Comment