Click to See Complete Forum and Search --> : Forms to separate recipients...
ba-doyn
05-10-2010, 02:57 PM
Not exactly sure where to post this one, so I'll give it a try here...
I'm doing a donation form that consists of information the client (a school) wants to capture about the donor, plus have it process the donation information to a secure processing site.
Now my issue...
I have it working where the total is passed to the sure processing site and all works well. Now I would like to send the remaining data to another recipient, a contact at the school which will collect the information. I have an address to a script in another form that sends that data to a recipient, and that works fine.
How might I combine the two?
I'm not much of a coder, so any help is greatly appreciated.
Thanks,
Michael
Which server-side language are you using?
ba-doyn
05-12-2010, 10:46 AM
Thanks for the response. Sorry for the delay, was out yesterday.
Here's what I have:
- on clicking the submit button, the total to be donated is passed to the secure server for the user to fill out their payment info.
- I would also like to capture all the information (name, address, plus all sorts of stuff) and send it to the school contact. On another info form I have an address that uses the formmail.cgi script.
Is this what you need?
Hope this helps.
Thanks,
Michael
Normally the data is sent to the server script, which splits the data and sends that to the required recipient(s). Ideally the server script must be change to accomplish this.
It could possible be done with a hidden iframe and JavaScript, or if the secure server returns data to your page, to use this to send an email.
ba-doyn
05-13-2010, 01:04 PM
I'm a bit confused as I'm not much of a code person, so can I restate what I need to help me understand it better?
I have one address that directs the user, plus the donation amount, to the secure server for payment.
I also have an address that will process the form data and send it to an email address.
How can I get both addresses to work on one form?
Hope that helps.
Michael
Ideally the server script needs to be changed.
ba-doyn
05-13-2010, 09:41 PM
Fang,
Imagine you are talking to a clueless coder... cause that's what I am. :-)
What exactly do you mean?
This seems like such a simple thing, why am I so stumped?
Thanks,
Michael
When you send the data to the payment site, all entered data is lost, unless this is saved in some way or the payment site returns a confirmation page with the data.
You can't send data to 2 sites simultaneously unless you:
1. send data to your server sctipt which splits the data to the 2 addresses. <- ideal solution
2. use an iframe to send part of the data to a 2nd address
3. use Ajax in combination with a server script to send part of the data to a 2nd address
ba-doyn
05-14-2010, 07:58 AM
Now I'm understanding a bit more. Thanks for dumbing it down for me.
Now, how/where do I go about solving this, for all steps?
Thanks for you patience and help.
Michael
Does the payment site return any values?
ba-doyn
05-14-2010, 08:30 AM
Not sure what you mean... Once the user goes to the payment site, the donation value is carried from the form, the user then fills out the payment info, and once it's confirmed/rejected, it sends them to a thanks/error pages.
Does that help?
Michael
You could try this. It creates a hidden frame in the document which contains a copy of itself.
After filling-out the form you press submit button which copies the data to the hidden form, submits it to your form.cgi, then submits the data to the payment site.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
window.onload=function() {
if (top == self) {
var hiddenFrame = null;
try { //IE
hiddenFrame=document.createElement('<iframe name="school" src="">');
}
catch(e) { // W3C compliant
elm = document.createElement('input');
var hiddenFrame = document.createElement('iframe');
hiddenFrame.name = 'school';
}
hiddenFrame.style.display = 'none'; // hide it
document.body.appendChild(hiddenFrame);
school.location.href = location.href;
var button=document.getElementsByTagName('button')[0]; // maybe different in your case
document.donation.onsubmit = function() {copyToIframe();};
}
};
function copyToIframe() {
var f = document.donation; // change 'donation' to the name of your form
var s = school.document.donation; // ditto
for (var i=0; i<= s.length-1; i++) {
if(f[i].type=='checkbox' || f[i].type=='radio') {
if(f[i].checked) {s[i].checked = true;}
}
else {
s[i].value = f[i].value;
}
}
s.action = 'formmail.cgi'; // your cgi script
s.submit();
}
</script>
<style type="text/css">
* {margin:0;padding:0;}
</style>
</head>
<body>
<form action="paymentSite.cgi" method="post" name="donation">
<label>name: <input type="text" name="name"></label>
<label>email: <input type="text" name="email"></label>
<label>amount: <input type="text" name="amount"></label>
<button type="submit">submit</button>
</form>
</body>
</html>
You have to copy the script to your document, make changes where necessary and configure your formmail.cgi
ba-doyn
05-14-2010, 11:39 AM
Wow. Thanks.
I'll give it a try today and let you know.
Thanks.
Michael
ba-doyn
05-14-2010, 08:49 PM
Thanks again for all your help.
I have a couple of questions about the script you gave me...
- I need just the script, correct?
- I saw your comments, so I just have to replace a few things, I assume:
- what is "hide it"?
- what do you mean by "maybe different in your case"?
- the name of my form is "donation" - good guess :-)
- I inserted my cgi script that was given to me
- Where do I put where the information go to?
- Does this script collect all the fields?
I think that's all my questions (so far).
I appreciate your help with this.
Michael
I need just the script, correct?Yes, and your own server script, formmail.cgi, correctly configured.
what is "hide it"?This hides the iframe from the user. Having it visible would only confuse them.
what do you mean by "maybe different in your case"?I referenced a button element to fire the function when submitting. You could be using an input, image or plain anchor to do this. I also don't know if you have a validation function which could interfere with the process.
the name of my form is "donation" - good guess :-)Shall I now guess your password? ;)
I inserted my cgi script that was given to me
- Where do I put where the information go to?You will have to know how the cgi script is configured. That should be explained in it's documentation.
Does this script collect all the fields?Yes, but it's the cgi script that will actually save only what you require.
The solution given is a generic one. It would be possible to create a specific set of fields in a form in the iframe, or load an existing document tailored to you requirements. This would require knowing all form control name's and type's.
ba-doyn
05-15-2010, 09:11 AM
Thanks for the help, but I'm still stuck in that "not knowing what the heck you're completely talking about" mode. :-)
I uploaded the page if you want to take a look at it. I would appreciate it.
check here (http://ba-doyn.com/junk/donation_form_test.html)
I'm doing this to help a friend at the school, and you know the old saying, "No good deed goes unpunished."
Thanks,
Michael
Remove this:<body onload="MM_preloadImages('images/top_nav/about_on.jpg','images/top_nav/program_on.jpg','images/top_nav/campus_on.jpg','images/top_nav/admissions_on.jpg','images/top_nav/alumni_on.jpg','images/top_nav/contact_on.jpg','images/top_nav/login_on.jpg')">
<div id="page-wrap">
<div id="top_banner"> </div>
and place the removed code here:window.onload=function() {
MM_preloadImages('images/top_nav/about_on.jpg','images/top_nav/program_on.jpg','images/top_nav/campus_on.jpg','images/top_nav/admissions_on.jpg','images/top_nav/alumni_on.jpg','images/top_nav/contact_on.jpg','images/top_nav/login_on.jpg');
if (top == self) {
var hiddenFrame = null;
try { //IE
hiddenFrame=document.createElement('<iframe name="school" src="">');
}
catch(e) { // W3C compliant
elm = document.createElement('input');
var hiddenFrame = document.createElement('iframe');
hiddenFrame.name = 'school';
}
hiddenFrame.style.display = 'none'; // hide it
document.body.appendChild(hiddenFrame);
school.location.href = location.href;
var button = document.getElementById('submit'); // remove this line
document.donation.onsubmit = function() {copyToIframe();};
}
};
Now give it a try.
ba-doyn
05-15-2010, 02:12 PM
Thank you so much.
What I did was remove the red "onload" code, as in the top example, and moved it to the script, as you have in blue in the bottom example. I also removed the line in red in the bottom example. Correct?
I appreciate the help. I will give it a try.
Michael
ba-doyn
05-18-2010, 07:42 AM
Thanks again for all your help.
I put in the code like you mentioned and the recipient still is not receiving the form info.
Also, out of curiosity, I changed the iframe to "screen" and couldn't see it anywhere. Where would it be located? I then changed it back to "none" so I didn't screw things up.
I re-uploaded the file. Can you check it again?
Thanks,
Michael
Comment out this line, the iframe should be visible if you have it configured correctly.hiddenFrame.style.display = 'none';
I put in the code like you mentioned and the recipient still is not receiving the form infoHas the cgi script been configured correctly?
ba-doyn
05-18-2010, 10:33 AM
The cgi script is just an address given by the host. What would I need to do to configure the script correctly?
Also, what is the time difference where you are? I'm in the midwest US.
Thanks,
M
What would I need to do to configure the script correctlyThat would depend on the script. Some have a catch all others must be configured to accept specific field names.
Time difference is 7 hours.
ba-doyn
05-20-2010, 07:35 AM
Great. I'll check right away.
Thanks,
Michael