: Web Programmers - Help! - Posting Form Data to 2 Actions

Mar 30th, 2008, 09:28 PM
Fellow web programmers. Here is my dilemma:

I have a webform. Rather extensive. It collects a lot of data for a client.

All the web form data has to be processed through a mailform script to be sent to the client AND that same form data has to be sent to a payment processor.

I don't need to see the results of the email sent, but I do need the payment processors page to come to the front so that whoever is entering information on the webform can follow through with credit card payment.

I've googled myself to death looking for a solution.

One solution recommended using JS an iframes, but I could not get it to bring the credit card processor page to the front AND email the form data.

Any recommendations? It's a lot of form data so processing the individual fields one-by-one isn't an option. Plus the webform will be updated on a regular basis, so a highly customized back-end script for handling individual fields isn't feasible either.


Mar 31st, 2008, 07:16 AM
I use PHP to write my web apps. In this case, I would have the script action do both actions, rather than think of having two scripts perform one!

I'm not sure why you can't process the fields individually -- how many are you talking about? You're only doing this once. You could push the whole $_POST array to the new page by serializing it, and then using header() to move to the new page.

$field1 = $_POST["field1"];
// process additional fields from form here...

$postdata = serialize($_POST);
header("Location: newpage.php?data=".$postdata);

You can use a session var as your persistence mechanism; hell, I don't know if this code even works, but it should give you an idea.

On the last page, you put the serialized post data back into an array by employing unserialize().

Good luck!