I'm finishing up a simple registration form and am running into some difficulty handling a redirect. In my case, there is a final "submit" input that passes a hidden session value that is used to gather user data from the database. This non-sensitive data then requires two actions:

1) An email is generated to the "owner" with the contents of the "order".

2) The user is redirected to PayPal, along with a series of hidden form values.

The first requirement is successful, but the second is causing errors. I've never attempted a redirect with CGI, much less one with hidden form values, so it's quite likely I'm screwing the pooch. In its current state, it results in the following Apache error:
malformed header from script. Bad header=HTTP/1.1 302 Moved: index.cgi
Here's the relevant sub. If anyone has any ideas, I'd love to hear them. Thanks!
sub paypal_redirect { my ($query, $total_cost) = @_; my $cgi = CGI->new; print $cgi->redirect(-uri => 'https://www.paypal.com/cgi-bin/w +ebscr', -nph => 1); print $cgi->start_form(-method => 'post'); 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->p +aram('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->end_form; }
-fp

In reply to Redirecting form data to external site by fuzzyping

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.