in reply to Re^5: Coding and Design Advice
in thread Coding and Design Advice

Hi,

Yes, it certainly appears straightforward. I also understand that the redirect will be based on the result of the button that is selected.

As for placing the redirect as the first header, do I place it before my conditional statement or after?

I'm not sure I follow "has to be the first header".

Thanks.

Replies are listed 'Best First'.
Re^7: Coding and Design Advice
by g0n (Priest) on Apr 01, 2005 at 12:34 UTC
    OK, the code will be something like:

    #!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; # construct and send confirmation emails here if you # want them to go to everyone if ($cgi->param('radiobutton') eq 'paypal') { # this sends a redirection header print $cgi->redirect('http://sendmetopaypal.com'); } else { # construct and send confirmation emails here if you # only want them to go to non paypal users print $cgi->header(), $cgi->start_html, "Thank you for booking, a confirmation email has been sent to +email\@address", $cgi->end_html; }

    What I meant by 'has to be the first header' is don't do this:

    #!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; print $cgi->header; print $cgi->redirect('http://redirecttohere.com');

    I've got stuck on that one a couple of times :-) In other words, don't forget that redirect is a header in it's own right - it doesn't need a $cgi->header sending before it.

    g0n, backpropagated monk
      Hi,

      Thank you for your reply. I assumed the exact scenario you mentioned at the end. I was thinking of doing what you said not to do.

      Thank you for your help.
      Hi,

      I believe I found one loophole with the redirect solution. PayPal provides a button which contains all the parameters which are needed to charge the persons credit card and place the money into the account of whom is receiving the payment.

      The way the current redirect statement is written it will take me to PayPal, but it won't pass any of the parameters for the event which need to be charged to the persons credit card.

      The PayPal button must be clicked first in order to be directed to PayPal. As I can tell, I don't think I'll be accomplishing this with the current code.
        It might be possible to twiddle the URL called by the redirect header. Can you post the code that constructs the paypal button on your page? - the original page was offline last time I tried.

        I also am offline for a while, but I'll take a look at this again tomorrow GMT.

        Update: The original page is back online, and there's a possible solution. Its a bit krufty - someone might be able to come up with a cleaner approach, perhaps using javascript to change the form action from the client side, but this seems to work OK. Change your redirect URL to:

        https://www.paypal.com/cgi-bin/webscr?add=1&cmd=_cart&business=MAILADDRESS&item_name=BridgeMill%20Power%20Tennis%20Camp&name=item_number=Camp05&amount=198.00&no_note=1&currency_code=USD&lc=US

        This is the URL taken from the form action, with all the fields that were supplied as hidden form parameters in the html source supplied as URL parameters.

        (You'll need to change the mail address to the correct one - I chopped it to combat spambots). You might also need to check your agreement with paypal to make sure you aren't obliged to display their button.

        Hope this helps.

        g0n, backpropagated monk