Since your question isn't clear to me, here are a few shots in the dark:

Assumption 1 (and begging the question of what triggers your original script): You are looking for a way to chain .cgi scripts.

OK. Let's say you have a script which, when executed on the server, generates a new .html page. The generated page (whether created with a heredoc (for example, the "here documents" section of quotes in Perl) or some other method (see, for example, the thread beginning at Template with optional PHP execution, which, despite the title, offers a quick survey of templating systems) looks something like this:

<Doctype ...> <html> <head> <title><metas><etc> </head> <body> <p>Some content</p> <form method="POST" action="cgi-bin/webmstr.cgi"> <input type="hidden" name="subject" value="somevalue" readonly> <FIELDSET> <LEGEND>Personal information</LEGEND> <LABEL for="firstname">First name: </LABEL> <input id="firstname" name="firstname" type="text" size="30"> <br> <LABEL for="comments">Please enter your submission here: </LABE +L> <br> <TEXTAREA id="comments" NAME="comments" ROWS="10" COLS="72"></TEXT +AREA> <!-- Button(s): --> <input type="submit" value="Send this form?">&nbsp; &nbsp; <input +type="reset"> <br> </FIELDSET> </form> ... </body> </html>

Note Line 8 which -- as one way I interpret your question -- is an answer to "is their (sic) a way to do an if statement like. if post request then do this?." When the user submits the form by clicking the submit button in the generated page, the browser uses the POST method to ask the server to execute webmstr.cgi. Your "if" is implicit: If the user doesn't click the submit button, nothing more happens. If the user does click submit, then whatever instructions you've placed in webmstr.cgi will be executed.

Another answer might be "Of course, but it's up to your script to identify what's being submitted in what circumstances and what do YOU want your script to do about it." However, a full tutorial on conditionals, cgi, etc, is beyond the ambit of this response.

Assumption 2: You knew all that and are wondering about passing data back to the same script for action on the response.

OK, that's also simple enough. Parse the parameters returned by the second submit for a relevant value (use a form id, for example), and, using an if (...) { clause;}, do something with the rest of the parameters.

Assumption 3: I'm entirely blind to your real question and intent.

That's certainly a possibility, in which case I can do no better than guess you may need to read the CGI.pm docs and available_tutstring (except that the linked there may be down [discussion: http://use.perl.org/~Ovid/journal/32708]).

Oh, come to think of it, yes I do have a better suggestion: read How do I post a question effectively? and "show us some code."


In reply to Re: Form inside perl script by ww
in thread Form inside perl script by k0rn

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.