Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2006
    Location
    Bronx, New York
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Action: more than one?

    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.

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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.

    PHP Code:
    $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.


  • #3
    New Coder
    Join Date
    Feb 2006
    Location
    Bronx, New York
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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
    Ess

  • #5
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    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.


  •  

    Posting Permissions

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