Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-20 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found