|
Posted by Andrew Poelstra on 12/17/01 11:56
pengypenguin@gmail.com writes:
> axlq wrote:
>> How do I create a form that two submit buttons, where each one
>> submits the form input data to a different server?
>>
>> Consider this situation: I have a form where users can check various
>> options to subscribe to a service, and each option costs a certain
>> amount. When the form is submitted, my php script totals up the
>> options. Fine.
>>
>> The form has 2 submit buttons: "print invoice" and "pay by credit
>> card."
>>
>> The "print invoice" button is for those businesses who can't pay by
>> credit card but must mail us a check instead; they print an invoice
>> for their accounts payable department. The php script generates the
>> invoice based on the form inputs. Easy, no problem.
>>
>> The problem is "pay by credit card." The total cost from submitted
>> input fields must be POSTed to a different server: our credit card
>> processor.
>>
>> This isn't a problem if the credit card processor accepts the
>> form input data as a GET string in the URL; all I'd do is
>> header("Location: $url"); to redirect the user to the credit card
>> processor page which handles the payment. The problem is I need
>> to do this by POSTing the form input data, while at the same time
>> retain the ability to generate invoices from MY server using the
>> same form.
>>
>> I can't think of an elegant way to do this except to have two
>> different payment pages each with their own form. Or maybe force
>> everybody to generate an invoice as the first step, and after that
>> point they can choose to pay it by credit card.
>>
> What I did was to create a dummy action in the post form, and use a
> javascript function to swap in a new action and then call the submit
> method based on the onclick of different buttons.
>
Please don't top-post. I've corrected it above.
Also, Javascripting a critical part of a website is always a Bad
Idea. Many people, such as myself, have browsers that don't support
Javascript. Many people disable Javascript in their browsers to
avoid popups, ads, etc.
A better solution to this would be to create a confirmation page
for the credit card purchase which has an additional submit button
that goes only to the credit card company.
The confirmation page can be the invoice page, except that it checks
which button was clicked and either displays an invoice or a
confirmation (or both).
--
Andrew Poelstra <http://www.wpsoftware.net/projects>
To reach me by email, use `apoelstra' at the above domain.
"Do BOTH ends of the cable need to be plugged in?" -Anon.
Navigation:
[Reply to this message]
|