/    Sign up×
Community /Pin to ProfileBookmark

How to submit form data to 2 different places?

Hi,

I’m building a donation form on my site. So far, this page is just a basic HTML form that takes all the fields and submits them to a secure processing site, which then handles it from there.

My question is, when the user clicks “submit,” I would like to record some of the data in my own database as well, in addition to submitting it to the secure processing site.

Right now it’s a normal HTML form with post action set to the secure site’s URL. The other pages, which are currently submitting to the DB, post the form to the PHP code which calls the DB connection.

How can I have the one submit button do both things? I’m using Dreamweaver, btw (just mentioning in case there’s any simple way of doing it from there).

Thanks

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@hastxMar 28.2008 — There are different ways:

one is to direct to your own php page, gather your data and process the data to the database, then use the header function to re-direct to the secure site.

Or you could submit the form to a javascript for your own processing, then return to the form for processing to the secure site. But then you have the concern fi someone has javascript disabled.
Copy linkTweet thisAlerts:
@NogDogMar 28.2008 — You could also use the [url=http://www.php.net/curl]cURL functions[/url] to send the HTTP post/get transaction to the external site.
Copy linkTweet thisAlerts:
@rad850authorMar 30.2008 — Thanks for the replies.

I used cURL to do both entries at once, and it's working fine.

One problem though- the cURL routine gets the output from the secure page and prints it out (which is necessary because of a "proceed" button there that the user has to click). In the meanwhile, my own submit button is doing what it did before, which is that once the data's put into my DB, it returns a blank version of the form.

So the result is that I get a blank version of the form, with the secure site content ("proceed" button, etc.) right on top of it, but all jumbled up due to CSS of the form being applied to the whole thing. Ideally, I'd just have the secure site's content visible, and not the blank form (as it might confuse users into thinking they have to fill it up again) - how can I do this?

I was thinking maybe if there was some way of setting the main action to not go to a blank version of the form when it's done, and instead somehow clear the screen before the secure site content comes up, that might do it, but I'm not sure where to look...
Copy linkTweet thisAlerts:
@WebnerdMar 30.2008 — Post additionally to an IFRAME.

<i>
</i>&lt;script type="text/javascript"&gt;
function dual_submit(){
var f = document.forms[0];
f.setAttribute('target','_myHidFrame');
f.setAttribute('action', 'your url');
f.submit();

f.setAttribute('target','_self');
f.setAttribute('action','secure url');
f.submit();

}
&lt;/script&gt;

Assuming you have a hidden &lt;iframe&gt; named "_myHidFrame"


Copy linkTweet thisAlerts:
@foundbydesignAug 13.2008 — There are different ways:

one is to direct to your own php page, gather your data and process the data to the database, then use the header function to re-direct to the secure site.

Or you could submit the form to a javascript for your own processing, then return to the form for processing to the secure site. But then you have the concern fi someone has javascript disabled.[/QUOTE]



HASTX,

How would you accomplish this? I am still relatively new to some of the coding and want to accomplish this same thing. I have a form in which someone will request information, but I want the information gathered to 2 places. The main reason is because the system I am using for autoresponders does not have a pass-through function for the data. Some of the data collected will be used for calculations on the end page, but I want the autoresponder to also get this info.

Any ideas?
Copy linkTweet thisAlerts:
@TecBratAug 13.2008 — I've worked with Curl on several sites now, and it seems the right way to go. What I would suggest for your form is to wrap it in an "if" statement that looks for the status of the "submit" variable. The "else" would then echo the data from the curl.
Copy linkTweet thisAlerts:
@foundbydesignAug 13.2008 — I do not know how to use cURL. I looked at the PHP documentation, but I do not have the time to devote to figuring it out... any help would be appreciated
Copy linkTweet thisAlerts:
@TecBratAug 27.2008 — Try This and do some reading here and here
×

Success!

Help @rad850 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...