SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 2 functions with only one SUBMIT

    I got this routine of sending a mail and saving the info with mysql-asp. Look:

    form.htm -- post----> formtomail.cgi -- redirect --------> save.asp

    The problem is that the request.form() reaches save.asp empty, because obiously nobody submitted a form in the CGI.

    How can I save the data then?

    Does exist any code combination to save first, and then (without pressing any submit button, but redirecting automatically) go to the CGI? I mean:

    form.htm -----> save.asp ---redirect automatically, as it where a form----> CGI.

    I want to know if it is posible something like this.

    Another idea suggested a session object declared in a suppoused form.asp.

    What I need is to store the data and send the mail only pression one submit button.

    Thanks a lot.

    PD: Where is a forum to discuss CGI Issues and programming? I couldnt find it here.

  2. #2
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Combine form.htm and save.asp into one file. When the user submits the form, save the data and then submit to the CGI app.
    For example:
    Code:
    <form id="aForm" method="POST" action="formmail.cgi" onsubmit="doSubmit(this.form)">
        <!-- Form voodoo -->
    </form>
    <script type="text/javascript">
        function doSubmit(form){
            /* Save form voodoo here */
            form.submit()
        }
    </script>
    This should work even though I haven't tested it.
    Rob Nolan
    Do or do not, there is no try.

  3. #3
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RogueJedi, can you explain me a bit what do those lines?
    Also, Do I need to place some SSI or adjust any configuration with the hosting service to run that?

    Thanx

  4. #4
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is nothing happening here that would require a change on your host, just to the pages involved. You may or may not need SSI includes depending on how your host has things set up and/or if you want to keep parts of your code separate.

    In the page with your form the code

    Code:
    <form id="aForm" method="POST" action="formmail.cgi" onsubmit="doSubmit(this.form)">
        <!-- Form voodoo -->
    </form>
    will submit the form to the formmail.cgi program. The form uses the HTTP POST method to send the data. Using the GET method would pass the data as part of the URL string, which is limited to about 255 characters, I think. This may not be long enough, and could also be a security risk if passwords are involved.

    Before it actually submits the form it calls the code

    Code:
    <script type="text/javascript">
        function doSubmit(form){
            /* Save form voodoo here */
            form.submit()
        }
    </script>
    in which you have the code necessary to save your data. After the data have been saved, it calls the form's submit() function to send the data on to the formmail.cgi program.

    You should be able to do all of this one page, eliminating save.asp and leaving you with

    form.asp -----> formmail.cgi

    Check out the form handling tutorials at the ASP 101 web site

    I hope that clears things up a bit.
    Rob Nolan
    Do or do not, there is no try.


Bookmarks

Posting Permissions

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