Hi,
I have this cgi script which is a simple authentication web page, it check the value of the password_field and if correct call the subroutine alfa.
I don't know why it stops with an error when I click on "insert new stream"
I tried to call the subroutine without the authentication part and it works.
I have this cgi script which is a simple authentication web page, it check the value of the password_field and if correct call the subroutine alfa.
I don't know why it stops with an error when I click on "insert new stream"
I tried to call the subroutine without the authentication part and it works.
Code:
#!/usr/bin/perl -Tw
use CGI;
$query = new CGI;
print $query->header;
print $query->start_html();
if (!$query->param) {
print $query->startform;
print $query->password_field(-name=>'the_password',
-size=>35,
-maxlength=>50);
print $query->br;
print $query->submit(-value=>'Submit your password');
print $query->endform;
} else {
$yourPassword = $query->param('the_password');
if ($yourPassword eq '123') { [B]alfa ();[/B]} {print 'error';}
}
print $query->end_html;
sub [B]alfa[/B] () {
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;
my $mode = param('mode');
my $url = url;
print header,
start_html;
print h2('insert values'),
start_form(),
textfield('DETAILS'), 'detail bor bla bla..' . br,
textfield('TARGET_DATABASE') . br ,
textfield('TARGET_HOST'). br,
textfield('TARGET_IP') . br,
textfield('TARGET_ACCOUNT') . br,
textfield('SOURCE_DATABASE') . br,
textfield('SOURCE_HOST'). br,
textfield('SOUCE_IP') . br,
textfield('SOURCE_ACCOUNT') . br,
textfield('STREAM_NAME') . br,
textfield('ID') . br,
submit('insert new stream'),
end_form;
if($mode eq 'process_form')
{
my $dbh = DBI->connect('DBI:Oracle:(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = xxxx)))(CONNECT_DATA =(SERVICE_
NAME = xxxxxxx)))', 'monitor', 'monitor', {RaiseError=>'1'});
my $sth = $dbh->prepare('insert into s_test (DETAILS, TARGET_DATABASE, TARGET_HOST, TARGET_IP, TARGET_ACCOUNT, SOURCE_DATABASE, SOURCE_HOST, SOUCE_IP, S
OURCE_ACCOUNT,STREAM_NAME, ID) values (? , ? , ?, ?, ?, ?, ?, ?, ?, ?, ?)');
$sth->execute(param('DETAILS'), param('TARGET_DATABASE'), param('TARGET_HOST'), param('TARGET_IP'), param('TARGET_ACCOUNT'), param('SOURCE_DATABASE
'), param('SOURCE_HOST'), param('SOUCE_IP'), param('SOURCE_ACCOUNT'),param('STREAM_NAME'), param('ID'));
$dbh->disconnect;
}
print end_html;
}
Comment