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


In reply to Passing results to a script after form element validation by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.