I have a form which I need to POST to multiple scripts. How can I do this the simplest way?
I know it could be done with Javascript, Curl or Snoopy class, but really
I just had to do this with ASP. I wanted to post a form to an email processing script on one domain and record the action on a MySQL database on a different domain with one button click. This could also be useful in any number of other situations.
There is no way to have multiple ACTIONS on an HTML form definition. So, just send it on to one location, process the form, and then "repost" the form to another location. You can do this in a script "chain" of any length.
First add this ASP sub rountine to your script. If you are using PHP or some other language you can just translate this code to your own language and the concept will work.
sub RePost( Destination )
RePostString = "" & vbCRLF
if( (Trim(Destination) <> "") and (Request.ServerVariables("REQUEST_METHOD") = "POST") ) then
RePostString = RePostString & "" & vbCRLF & _
""
else
RePostString = "
Sorry! Internal Scripting Error Encountered!
" & vbCRLF
end if
RePostString = RePostString & ""
Response.Write( RePostString )
end sub
Then, at the end of your process, just finish with a call to the sub like this:
RePost "http://www.SomeOtherDomain.com/SomeOtherScript.asp"
If needed, repeat the chaining processes on all your scripts, and then in the end you probably want to redirect to a page on your orginal domain (where the form came from) or do something to display a success message to your users.