473,769 Members | 3,305 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
13 1989

Alvaro G. Vicario wrote:
*** 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.
I wouldn't say that. When implemented correctly client-side code
usually improves the user experience. I think people just need remember
a key advantage of (and motivation for) server-side programming: you
control the environment where the code runs. Client-side code is hard
to QA because there are many variables you can't control. Testing on
multiple platforms and configurations is tedious and could require more
manhours than writing the code in the first place.

Often when I hear the word AJAX I feel like beating the speaker over
the head with a big wooden spoon.

Aug 26 '06 #11
axlq wrote:
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.
You can redirect a POST with the HTTP status code 307. That only works
well with Internet Explorer though. Firefox would pop up a warning
message. Don't know if the issue's been fixed or not.

Aug 26 '06 #12
*** Chung Leong escribió/wrote (26 Aug 2006 12:01:11 -0700):
You can redirect a POST with the HTTP status code 307. That only works
well with Internet Explorer though. Firefox would pop up a warning
message. Don't know if the issue's been fixed or not.
Firefox 1.5.0.6 pops up a warning message prompting whether you want to
resubmit the data to the new page.

--
-+ 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 27 '06 #13
On 2006-08-24 11:57:46 -0600, ax**@spamcop.ne t (axlq) said:
>
How do I create a form that two submit buttons, where each one
submits the form input data to a different server?
It's not too hard. Have two submit buttons and then choose your action
based on which one was chosen.

=============== ===============
form
=============== ===============

<form action="handler .php" method="post">
Order form stuff
<input type="submit" name="invoice" value="Print invoice" />
<input type="submit" name="creditcar d" value="Pay via credit card" />
</form>

=============== ===============
handler.php
=============== ===============

<?php
if (isset($_POST['invoice'])) {
Print an invoice
}
if (isset($_POST['creditcard'])) {
Pay via credit card
}
?>

If your using two different servers as your post suggests you can just
redirect the data to the correct location in the if() statement,
otherwise just add the appropriate code or include the appropriate file
in the if(). Hope that helps.

Aug 29 '06 #14

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

Similar topics

7
2601
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
5097
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
2540
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
7240
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
1718
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
9589
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
9423
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
10216
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
10049
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
8873
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
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.