www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Forms to separate recipients...

  1. #1
    Join Date
    May 2010
    Posts
    13

    Forms to separate recipients...

    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

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Which server-side language are you using?

  3. #3
    Join Date
    May 2010
    Posts
    13
    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

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    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.

  5. #5
    Join Date
    May 2010
    Posts
    13
    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

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Ideally the server script needs to be changed.

  7. #7
    Join Date
    May 2010
    Posts
    13
    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

  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    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

  9. #9
    Join Date
    May 2010
    Posts
    13
    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

  10. #10
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Does the payment site return any values?

  11. #11
    Join Date
    May 2010
    Posts
    13
    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

  12. #12
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    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.
    Code:
    <!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
    Last edited by Fang; 05-14-2010 at 11:20 AM. Reason: added checked control verification

  13. #13
    Join Date
    May 2010
    Posts
    13
    Wow. Thanks.

    I'll give it a try today and let you know.

    Thanks.
    Michael

  14. #14
    Join Date
    May 2010
    Posts
    13
    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

  15. #15
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles