http://qs321.pair.com?node_id=344977

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,

I have put some validation onto a form so to ensure that a field gets filled. This works fine for me, except now I want the form elements to get passed onto another cgi script. Here's a bit of the code

# Process form if submitted; otherwise display it if ($co->param("submit")){ process_form ( ); }else{ display_form ( ); } sub process_form{ if ( validate_form()){ print $co->start_form( -method=>'POST', -action=>"http://mywebserver/cgi-bin/script2.cgi +", ), $co->end_form(), $co->end_html; END{} } } sub validate_form{ my $searchfield = $co->param("searchfield"); my $error_message = ""; $error_message .= "Please enter a value into the searchfield<b +r>" if ( $searchfield eq "" ); if ($error_message){ # Errors with the form - redisplay it and return failu +re display_form ( $error_message, $searchfield, ); return 0; }else{ # Form OK - return success return 1; } }
The display_form sub simply displays the main page, starts like this
sub display_form{ my $error_message = shift; my $searchfield = shift; print $co->start_form( -method=>'POST', -action=>"http://mywebserver/cgi-bin/script1.cgi +", ), . . . #loads of extra stuff here . . $co->hidden( -name=>'submit', -value=> "Submit"), ), $co->end_form(),
Everything works fine, except the sub process_form, I would like this sub to send my fields onto script2.cgi for further processing (i.e. as if a hidden submit button on this form was automatically pressed - can this be done) can anybody direct me into the right direction for doing this.

Also, I was wondering, (and I really don't mean to offend anyone here) are the scripts used to create the perlmonks website available to take a look at or even download?

Thanks in advance,
Jonathan