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

I have a form that has a confirmation page that I do not want to touch but I want to mail the form data entries using my Perl mail script. How or where can I call the Perl mail script because I dont want change the action confirmation page. Can I call it on the action page such as this:
<body onload="perlmail.pl"> action page stuff here ...</body>
Or how would I do this? Here is my action and validation area:
<FORM id="idhere" name="sandiego" method="post" action="confirm.asp" o +nsubmit="return validatetheForm(this)">
I dont think I can do something like this?
<FORM id="idhere" name="sandiego" method="post" action="confirm.asp;pe +rlmail.pl" onsubmit="return validatetheForm(this)">

Replies are listed 'Best First'.
Re: Where to call script
by Happy-the-monk (Canon) on Mar 10, 2004 at 13:13 UTC

    change the form tag's to action="newtask.perl" or similar.
    Create the new script and do what needs to be done in it.
    If the confirm.asp is also in Perl, just require it in the new script.
    If it isn't, call it with redirection - see CGI and look for the redirect-method.

    Sören

      Redirecting the request will only work if it is a GET request, but not if it's a PUT request.

      If a PUT request is needed, the best way is to use LWP::UserAgent to do another PUT request in the background.

Re: Where to call script
by UnderMine (Friar) on Mar 10, 2004 at 13:14 UTC
    Various possible solutions are :-
    • The target asp has an 'onload' with Javascript to popup a new window. Messy
    • Target action points to the perl which redirects to the asp. Note: email will be sent before showing confirmation.
    • Target action points to the perl which fetches and displays the asp page using LWP. Note: email can be sent before or after showing confirmation.
    Just a few ideas
    UnderMine
      What does the redirect look like in Perl? Would I put it at the end of my script? Is this correct???
      use CGI; use strict; #mail stuff here redirect('actionpage.asp');
        Two suggestions :-
        • Use the full url of the target.
        • Above will not pass parameters on to the asp. You need to include those also in the get.

        Undermine