URL problem when submit button pressed

64 views
Skip to first unread message

Harry Jamieson

unread,
Oct 8, 2012, 4:15:36 PM10/8/12
to perl-for...@googlegroups.com
Hi.  I have been programming for nearly 40 years now, but am new to Perl and FormBuilder.  However, I have managed to write a Formbuilder script that reads in a record from a database and updates that record when I hit the submit button.  The only problem that I'm having with it is that when I hit the submit button my cgi-bin folder (scripts) is showing twice in my URL.  When I correct the URL and hit the enter key, the confirmation screen comes up as it should.  Here is my action line when I just run the script using perl from the command line.  the script name is "conn2.pl".

<!-- Generated by CGI::FormBuilder v3.08 available from www.formbuilder.org -->
<form action="conn2.pl" method="get">

Here is the URL when I submit it to by browser (Google Chrome in this case).


When I look at the source, though, the action line looks like this

<form action="conn2.pl/scripts/conn2.pl" method="get">

And when I hit submit, my URL looks like this


Which of course results in an error 404.

Here is my code (please don't laugh!). :)

#!C:\perl\bin\perl.exe use strict; use warnings; use DBI; use CGI::FormBuilder; my @pref_fields; my @row; my $defs; my @ps_signer_opts; my @mult_out_fles_opts; my @pallet_min_wgt_opts; my @auto_nonauto_sort_opts; my @cont_sort_type_opts; my @ps8125_mailer_info_opts; my @auto_start_sentry_opts; my @move_update_opts; my @consol_stmt_opts; my @tray_opts; my $sqlstmt; #------------------------------------------ #get Preferences record. #------------------------------------------ #open connection to Access database my $dbh = DBI->connect('dbi:ODBC:driver=Microsoft Access Driver (*.mdb);dbq=hypersort.mdb', "sa" ,"xxxxxxx"); #prepare and execute SQL statement my $sqlstatement="SELECT * FROM Preferences"; my $pristh = $dbh->prepare($sqlstatement); $pristh->execute || die "Could not execute SQL statement ... maybe invalid?"; my $pref_fields=$pristh->{NUM_OF_FIELDS}; my $ctr=0; while($ctr < $pref_fields) { $pref_fields[$ctr] = $pristh->{NAME}[$ctr]; $ctr++; } $defs = $pristh->fetchrow_hashref; #------------------------------------------ #Get options for controls. #------------------------------------------ &get_ps_signer_opts; &get_mult_out_files_opts; &get_pal_min_wgt_opts; &get_auto_nonauto_sort_opts; &get_cont_sort_type_opts; &get_8125_mailer_info_opts; &get_auto_start_sentry_opts; &get_move_update_opts; &get_consol_stmt_opts; #------------------------------------------ # Init new form. #------------------------------------------ my $form = CGI::FormBuilder->new( title => 'HyperSort Preferences', fields => \@pref_fields, values => $defs ); #------------------------------------------ # Assign options to controls. #------------------------------------------ $form->field(name => 'DefaultStmtSigner', options => \@ps_signer_opts); $form->field(name => 'DefaultMultipleOutputFiles', options => \@mult_out_fles_opts); $form->field(name => 'DefaultPalMinWgt', options => \@pallet_min_wgt_opts); $form->field(name => 'DefaultPieceChoice', options => [qw(I N)]); $form->field(name => 'DefaultNonAutoSortYN', options => \@auto_nonauto_sort_opts); $form->field(name => 'DefaultContSortType', options => \@cont_sort_type_opts); $form->field(name => 'DefaultPS8125MailerInfo', options => \@ps8125_mailer_info_opts); $form->field(name => 'AutoSentryRun', options => \@auto_start_sentry_opts); $form->field(name => 'DefaultMoveUpdate', options => \@move_update_opts); $form->field(name => 'DefaultConsolStmtOption', options => \@consol_stmt_opts); $form->field(name => 'DefaultWeightUnit', options => [qw(O P)]); #------------------------------------------ # Check to see if we're submitted and valid #------------------------------------------ if ($form->submitted && $form->validate) { #Update database. $sqlstmt= "UPDATE Preferences SET DefaultOriginZIP = " . $form->field(name => 'DefaultOriginZIP'); my $pristh = $dbh->prepare($sqlstmt); $pristh->execute || die "Could not execute SQL statement ... maybe invalid?"; $pristh->finish; $dbh->disconnect(); print $form->confirm(header => 1); } else { # Print out the form print $form->render(header => 1); } exit(0); #------------------------------------------ # Get values for pssigner opts. #------------------------------------------ sub get_ps_signer_opts { #prepare and execute SQL statement my $sqlstatement=qq/SELECT PSSigner FROM DefaultDropDowns where len(PSSigner) > 0/; my $sth = $dbh->prepare($sqlstatement); $sth->execute() || die "Could not execute SQL statement ... maybe invalid?"; my $ctr=0; while($ps_signer_opts[$ctr] = $sth->fetchrow_array) { $ctr++; } pop (@ps_signer_opts); $sth->finish; } #------------------------------------------ # Get values for multiple output files opts. #------------------------------------------ sub get_mult_out_files_opts { #prepare and execute SQL statement my $sqlstatement=qq/SELECT YN FROM DefaultDropDowns where len(YN) > 0/; my $sth = $dbh->prepare($sqlstatement); $sth->execute() || die "Could not execute SQL statement ... maybe invalid?"; my $ctr=0; while($mult_out_fles_opts[$ctr] = $sth->fetchrow_array) { $ctr++; } pop (@mult_out_fles_opts); $sth->finish; } #------------------------------------------ # Get values for pallet min wgt opts. #------------------------------------------ sub get_pal_min_wgt_opts { #prepare and execute SQL statement my $sqlstatement=qq/SELECT PalletMinWeights FROM DefaultDropDowns where len(PalletMinWeights) > 0/; my $sth = $dbh->prepare($sqlstatement); $sth->execute() || die "Could not execute SQL statement ... maybe invalid?"; my $ctr=0; while($pallet_min_wgt_opts[$ctr] = $sth->fetchrow_array) { $ctr++; } pop (@pallet_min_wgt_opts); $sth->finish; } .
.
.
.
.
more subroutines to get options.....

I would appreciate any help that I can get!

Harry Jamieson

unread,
Oct 8, 2012, 4:35:54 PM10/8/12
to perl-for...@googlegroups.com
Sorry.  I meant to add that I am on Windows XP Pro SP3 running IIS 5.1 and ActivePerl 5.14.2 Build 1402.  My version of FormBuilder is 3.08.

Norton Allen

unread,
Oct 8, 2012, 5:25:46 PM10/8/12
to perl-for...@googlegroups.com, Harry Jamieson
Harry, I'm not quite sure what's going wrong, but I do know that when I create a form, I set the action property explicitly, so perhaps:
my $form = CGI::FormBuilder->new( title => 'HyperSort Preferences', fields => \@pref_fields, values => $defs,
action => '/scripts/conn2.pl'
 );
would do the trick.

-Norton
--
You received this message because you are subscribed to the Google Groups "perl-formbuilder" group.
To view this discussion on the web visit https://groups.google.com/d/msg/perl-formbuilder/-/X05RXA5GXfoJ.
To post to this group, send email to perl-for...@googlegroups.com.
To unsubscribe from this group, send email to perl-formbuild...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/perl-formbuilder?hl=en.

Harry Jamieson

unread,
Oct 10, 2012, 3:03:20 PM10/10/12
to perl-for...@googlegroups.com, Harry Jamieson, al...@huarp.harvard.edu
Thank you!  That solved the problem!  I appreciate it! :)

Harry
Reply all
Reply to author
Forward
0 new messages