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

I have several perl files, which each pass a transaction code (this is on a shopping site) from one to the other. In the last perl file, it calls a HTML file using the following code:
<form method="get" name="f1" action="finalorderpage.shtml"> <INPUT TYPE="hidden" NAME="VendorTxCode" VALUE=$VendorTxCode> <INPUT TYPE="image" SRC="proceed3.gif" VALUE="Submit the Order details +" ALIGN="left" width="75" height="27"> </form>
So as you can see, the $VendorTxCode is passed in a hidden field to the HTML page. However, I then need to retrieve this in the HTML file to use again as a hidden field. The code would is in the URL for example: http://www.domainhere.com/finalorderpage.shtml?VendorTxCode=23364876 But how do I retrieve this into the HTML document? Please do not say change the HTML document into a perl file as I cannot do this - it has to stay as a HTML document. Please help - this is probably something really simple but I am tearing my hair out :-S Thanks.

Replies are listed 'Best First'.
Re: Retrieving Data
by dws (Chancellor) on Nov 20, 2002 at 04:03 UTC
    Please do not say change the HTML document into a perl file as I cannot do this - it has to stay as a HTML document.

    If you have an HTML document and need to stuff a value into a hidden field in a form before sending the document to a browser, then open the HTML document from a CGI, read it into memory, perform a substitution to inject the hidden value, and print the result. It's that simple.

    Or, you can use one of the available templating mechanisms, like HTML::Template, which know how to read templates (HTML files with special directives), and make substitions.

Re: Retrieving Data
by BrowserUk (Patriarch) on Nov 20, 2002 at 02:22 UTC

    Unless I'm misunderstanding your question (which could be a little clearer:), instead of adding the tx code as a hidden field in the form that invokes the final html form, add the code directly to the url as below.

    <form method="get" name="f1" action="finalorderpage.shtml?VendorTxCode +=$VendorTxCode"> <INPUT TYPE="image" SRC="proceed3.gif" VALUE="Submit the Order details +" ALIGN="left" width="75" height="27"> </form>

    Of course, once you have removed the hidden field, then there is no reason (from your snippet) to use a form anymore, you could generate an anchor as

    <a href="finalorderpage.shtml?VendorTxCode=$VendorTxCode"> <img SRC="proceed3.gif" width="75" height="27"/></a>

    Re-reading this, I am really not sure I am answering your question, but then I'm not really sure what your question is. If I got it way wrong, just kick me!


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

      On the HTML page, I need to use the hidden field again to put into an e-mail and send the transaction code to admin staff,
        I don't see what you are trying to do, the static html file that you are trying to drop the hidden field on cant "do" anything with it.. Can you please try to reword your question with an example outcome.

        -Waswas
Re: Retrieving Data
by valdez (Monsignor) on Nov 20, 2002 at 10:19 UTC

    If I understood correctly, you want to read VendorTxCode from inside finalorderpage.shtml, probably using some kind of 'server side include' script. In that case I would do something like:

    # inside finalorderpage.shtml <!--#include virtual="/cgi-bin/intercept.cgi"> # intercept.cgi #!/usr/bin/perl use CGI; # scripts executed via SSI don't get usual informations, # so we must rebuild the query passed to our calling page # using %ENV (it's a dirty trick) my $req_uri = $ENV{REQUEST_URI}; my $query_string = substr($req_uri, index($req_uri, '?')+1); my $q = new CGI($query_string); print $q->header('text/html'); print "You called me with VendorTxCode=", $q->param('VendorTxCode');

    There are a lot of assumptions here...

    HTH, Valerio

Re: Retrieving Data
by perrin (Chancellor) on Nov 20, 2002 at 03:57 UTC
    Please do not say change the HTML document into a perl file as I cannot do this - it has to stay as a HTML document.

    Why? And if it does, what does this question have to do with Perl?

      Because the data is being passed by Perl!!!
Re: Retrieving Data
by lestrrat (Deacon) on Nov 20, 2002 at 02:18 UTC

    Why don't you just use javascript in the last page? of course, that means that if the browser does not understand javascript, your trasaction would fail...

    The Right Way is probably just to make the last page dynamic as well...

      Do you know any javascript that would do the job? The last page cannot be dynamic unfortunatley.

        not off of my head, unfortunately. I'm sure there are more experienced people in that kind of stuff around here..