View Full Version : Form Action: more than one?

11-02-2006, 01:51 PM
Can a form action have more than one url?

I have a form on my site that is being submitted to another website (aweber, a newsletter and autoresponder service). Before the data is sent out to that site and processed offsite, I want to save a record of the submission.

I would take the form data to a page on my site, record it into my database or whatever, then send the form data to the outside url.

Any advice on the best way to handle this would be greatly appreciated! Thanks.

11-02-2006, 03:32 PM
No, I don't think that you can submit, or have more than one URL to submit a form.

However, you can still achieve what you want, at the expense of forward the user to another server...where you want to perform your secondary processing.

You should have a page waiting for form submission. Once that page receives a submission...(note, you should make sure data is clean i.e. no sql injection), then it would process the data and then forward it to anther URL.

For example, in php, you can do the following.

$var1 = $_GET['var1'];
$var2 = $_GET['var2'];
$var3 = $_GET['var3' ];

// process the data locally such is storing in a file or database

// once done proceessing data locally, forward the data to antoher
// page located in another server.
header( "Location: http://secondary_server_url.com/target.php?var1=" . $var1 . "&var2=". $var2 . "&var3=" . $var3 . " );
exit(); // terminate header call

You can always return the user back to the server where they submitted the form originally.

I hope that helps.


11-02-2006, 03:38 PM
Thank you for your response.

The outside server that the form is sending to is expecting the data to be as by post method, not get, and I have no control over this or choice in the matter. Is there a way to send it by post after I process it on my site?

11-03-2006, 02:52 AM
I am not sure if that is possible without making the user click another button to send the data to the secondary server.

in other words...here is the process of how the data will travel from the form.
1- user fills in the form and clicks submit
2- the form submission is sent to a url in the same server
3- the url that receives the data will processes it (i.e. security, storage etc) and present a button to post the data to the second server.

In point 3, the user shouldn't be presented with the data they have just submitted. Only a confirmation that they have successfully upload data to the server and a button (note, data is stored in hidden fields) to further upload the same data to another server.

Please note that you can also make use of JavaScript, so that when the form is first submitted, you process it, and then dump it out in a form in the confirmation page. The trick is to create a function in JavaScript that will submit the form again but to the second server. If JavaScript has been disabled in the user's machine, than you present them with a submit button...otherwise...present them with a nice message confirming successful update.

I hope that helps.

All the best

11-04-2006, 07:54 PM
Hi donmarvin,

I just thought about another solution to this problem. However, it all depends on whether you are able to connect to the database on the secondary server remotely.

If you can....then you should submit your data to the remote database once you have validate the data and submitted it to the local database on your server.

I hope that helps.

Good luck.