473,757 Members | 10,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two different POST actions? Possible?


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("Locatio n: $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.

-A
Aug 24 '06 #1
13 1986
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.

-- whit

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("Locatio n: $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.

-A
Aug 24 '06 #2
pe**********@gm ail.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("Locati on: $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.
Aug 25 '06 #3
In article <11************ **********@h48g 2000cwc.googleg roups.com>,
<pe**********@g mail.comwrote:
>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.
I prefer not to rely on javascript for something this critical.
Javascript is fine for user convieniences such as form data
validation and expandable list trees, but the web site should
still function properly without it. A Lynx user should be able to
navigate through the form.

Using the invoice as a confirmation page before credit card purchase
seems like the best approach. Not what I want exactly, but it will
work.

-A
Aug 25 '06 #4
*** Andrew Poelstra escribió/wrote (Fri, 25 Aug 2006 14:25:01 GMT):
Many people disable Javascript in their browsers
Many developers love to think that users do so, but they don't :)

But of course JavaScript is the worst tool for critical tasks. Among many
other reasons, because developers who abuse JavaScript tend to be terrible
coders and their scripts fail in browsers that are not Internet Explorer
(and pretty often in IE itself). Good JavaScript coders just leave
scripting for auxiliary tasks.
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 25 '06 #5
NC
axlq wrote:
>
How do I create a form that two submit buttons, where each one
submits the form input data to a different server?
You can't. Just separate the forms. Like this:

<table>
<tr>
<td><form method="POST"
action="http://www.yoursite.co m/path/printinvoice.ph p">
<input type="hidden" name="custid" value="Customer _ID">
<input type="hidden" name="date" value="Date_of_ Invoice">
<!-- more fields if necessary -->
<input type="submit" value="Print Invoice">
</form>
<td>form method="POST"
action="https://www.yourpayment processor.com/path/">
<input type="hidden" name="merchantI D" value="Your_Mer chant__ID">
<input type="hidden" name="amount" value="Amount_o f_Payment">
<!-- more fields if necessary -->
<input type="submit" value="Pay by Credit Card">
</form>
</table>

The invoice printing script and the payment gateway are likely to
require different sets of data anyway...
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.
Not a bad idea, either.

Cheers,
NC

Aug 25 '06 #6
"Alvaro G. Vicario" <we*******@NOSP AMdemogracia.co mwrites:
*** Andrew Poelstra escribió/wrote (Fri, 25 Aug 2006 14:25:01 GMT):
>Many people disable Javascript in their browsers

Many developers love to think that users do so, but they don't :)
Okay, I'll bite. I'm a user and I use lynx. I also disable Javascript in
all my GUI-browsers so that I don't have to see popups and other crap.

Of course, you may argue that as a developer I don't count as a "user".
:-)
But of course JavaScript is the worst tool for critical tasks. Among many
other reasons, because developers who abuse JavaScript tend to be terrible
coders and their scripts fail in browsers that are not Internet Explorer
(and pretty often in IE itself). Good JavaScript coders just leave
scripting for auxiliary tasks.
That's definitely true; I have a grammar checker written in Javascript
(no, it doesn't work well enough for me to link to it here), and it takes
several seconds to parse only a few kilobytes of text. I have no idea what
it'd do if transferred to IE (there's virtually no IO, so I'd assume that
it would be fine).

Whereas the logic, if transferred to C, would run through thousands of
times that much text in as little time. On a processor only 10% as
powerful.

--
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.
Aug 25 '06 #7
In article <11************ *********@b28g2 000cwb.googlegr oups.com>,
NC <nc@iname.comwr ote:
>axlq wrote:
>How do I create a form that two submit buttons, where each one
submits the form input data to a different server?

You can't. Just separate the forms. Like this:
[snip]

Then I have redundant fields that need to be filled in twice. That's
exactly what I was trying to avoid. I wanted one form with two
submit buttons, each sending the data to a separate server.
>The invoice printing script and the payment gateway are likely to
require different sets of data anyway...
Why? I just use the payment gateway POST data to generate the
invoice.
>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.

Not a bad idea, either.
Based on the responses, it looks like that's the way to go.

-Alex
Aug 25 '06 #8
NC
axlq wrote:
>
The invoice printing script and the payment gateway are
likely to require different sets of data anyway...

Why? I just use the payment gateway POST data to generate
the invoice.
Why would you ever do that? You are giving away your (or your
customer's) internal information, which the payment processor is under
no obligation to safeguard. The only information you should give the
payment processor is that which is required to process payment (credit
card information and the amount). The rest (items and quantities)
should be kept internal.

Cheers,
NC

Aug 25 '06 #9
Many developers love to think that users do so, but they don't :)

Of course, you may argue that as a developer I don't count as a "user".
:-)
Both of these are very true. I used to work for a government office in
Finland. There was about 2500 employees. If I remember correctly, in IE
javascript was disabled as default. And stayed that way for most users,
naturally.

Aug 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2600
by: NotGiven | last post by:
Some have said to used GET for all quesries except those that manipulate/change a database. Some say use POST to quasi-hide parameters. Your thoughts?
1
439
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? I have read the doc regarding this: http://www.developer.com/net/asp/article.php/3385631 but it will not work when methods are in different services on
3
2458
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type System.Collections.Comparer has 1 members, number of members deserialized is 0. at System.Runtime.Serialization.Formatters.Binary.ReadObjectInfo.GetMemberTypes(String
17
5094
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also identifying memory leaks. The application in question is the Mozilla Web Browser. I also have had similar tasks before in the compiler construction area. And it is easy to come up with many more examples, where such kind of statistics can be very...
8
3508
by: Laith Zraikat | last post by:
I am trying to invoke a post request from code behind of an asp.net page using "WebClient" object, and I want the user to be redirected to the action url as well. So far Ive been able to send the post and get the response. using this code: Dim PostData as string Dim ActionURL as string Dim myWebClient As WebClient = New WebClient
40
2537
by: rdemyan via AccessMonster.com | last post by:
I have two databases, db1 and db2, with the same table, TableA. I want to select the records from TableA in db1 that have a LAST_UPDATE SomeDate. Then I want to get the identical records in TableA from db2. However the LAST_UPDATE dates will be different between db1 and db2. That's the point. If they are different, then there were changes made to the record in db1. I'm going to then process this further to find out what the changes were. ...
56
7235
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my website. The issue is that I need to gauge whether a user has any items in their basket to decide which page I redirect them too. I could
3
1717
by: squishywaffle | last post by:
Greetings, I've been trying to figure out if it's possible to attach a Python script to an action via Mac OSX Leopard's File Actions system. I'm wanting to call a Python script every time a file is added to the monitored folder. Just adding a .py file doesn't seem to do anything at all, and I can't find any log output anywhere to see what's going on. I'm more just looking to see if this is or is not possible. I'm not
9
1339
by: Carl Johansson | last post by:
If a multithreaded .NET application is executed on a computer with a multicore processor. Will the application automatically run the threads on different processor cores? Regards Carl Johansson
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.