Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Redirecting form data to external site

by Chady (Priest)
on Nov 21, 2003 at 07:59 UTC ( #308822=note: print w/ replies, xml ) Need Help??


in reply to Redirecting form data to external site

If you want to POST the data, you will need to generate a form to do it, and with the help of some javascript *ducks* you can make it autosubmit.

sub paypal_redirect { my ($query, $total_cost) = @_; my $cgi = CGI->new; print $cgi->header; # normal header print $cgi->start_form(-method => 'post', -action=>'https://www.paypal.com/cgi-bin +/webscr'); print $cgi->hidden(-name => '_cmd', -value => '_xclick'); print $cgi->hidden(-name => 'business', -value => $email); print $cgi->hidden(-name => 'item_name', -value => $comment); print $cgi->hidden(-name => 'item_number', -value => $query->pa +ram('session')); print $cgi->hidden(-name => 'amount', -value => $total_cost); print $cgi->hidden(-name => 'no_note', -value => 1); print $cgi->hidden(-name => 'currency_code', -value => 'USD'); print $cgi->submit('Continue to PayPal'); # you will need that +button in case # the user has JS off +. print $cgi->end_form; print <<JS; <script language="JavaScript"> <!-- document.forms[0].submit(); //--> </script> JS }

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/


Comment on Re: Redirecting form data to external site
Download Code
Re: Re: Redirecting form data to external site
by Anonymous Monk on Nov 21, 2003 at 10:09 UTC
    It's a good idea to use named forms (and then document.forms["formname"].submit();)
      If you want the JavaScript to work with a smaller number of browsers that is.

      Why is it a good idea to use named forms?

      In this instance you only lose by doing so.

      cLive ;-)

        Well, what if you have other forms before that one? Fine, use document.formname then

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://308822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-08-21 12:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (135 votes), past polls