Save html-forms data to local disk?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • grz02

    Save html-forms data to local disk?

    A question on html-forms:

    We have an application where users will get a CD with,
    among other things, some html-forms for them to fill in.
    When they click the submit-button, the data is transferred
    to a webserver php-script that will then process the info.
    The forms-definition looks something like this:

    <form action="http://www.ourdomain.c om/receiver.php" method="post">
    <p>Question 1:
    <p><textarea name="reply01" cols="40" rows="5"></textarea>
    <p>Question 2:
    <p><textarea name="reply02" cols="40" rows="5"></textarea>
    <p>Question 3:
    <p><textarea name="reply03" cols="40" rows="5"></textarea>
    ... etc ...
    <p><input type="submit" value="Submit answers!">
    </form>

    Now, my concern is (since there might be quite a lot of data filled in),
    if e.g. the internet-connection for some reason is broken
    at the moment when the user clicks the submit-button,
    there is a risk they will lose all the text and would have to re-type it,
    which I would like to avoid, of course.

    How can I best solve this issue?

    Ideally, I would like to store the info on their local C: drive
    before submitting, and automatically retrieve the text if they
    later return to the page, but I guess that's not possible from
    an html doc, right?

    If so, any other suggestions how to resolve this issue?

    TIA,
  • Geoff Berrow

    #2
    Re: Save html-forms data to local disk?

    I noticed that Message-ID:
    <1641ee43.04021 70821.4f5aebc0@ posting.google. com> from grz02 contained
    the following:
    [color=blue]
    >Ideally, I would like to store the info on their local C: drive
    >before submitting, and automatically retrieve the text if they
    >later return to the page, but I guess that's not possible from
    >an html doc, right?[/color]

    Don't think so.[color=blue]
    >
    >If so, any other suggestions how to resolve this issue?[/color]

    Submit each text area separately? Possibly on separate pages with a
    bit of javascript to take you to the next page.

    Of course if you need an internet connection to do this the page could
    come from the server with just a link on the CD.

    Then after submitting each textarea separately, you could repopulate it
    with the data

    <p><textarea name="reply01" cols="40" rows="5"><?php print
    $_POST['reply01']; ?></textarea>

    etc...
    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Chung Leong

      #3
      Re: Save html-forms data to local disk?

      Trying saving the data into the cookie using Javascript.

      Uzytkownik "grz02" <grz01@spray.se > napisal w wiadomosci
      news:1641ee43.0 402170821.4f5ae bc0@posting.goo gle.com...[color=blue]
      > A question on html-forms:
      >
      > We have an application where users will get a CD with,
      > among other things, some html-forms for them to fill in.
      > When they click the submit-button, the data is transferred
      > to a webserver php-script that will then process the info.
      > The forms-definition looks something like this:
      >
      > <form action="http://www.ourdomain.c om/receiver.php" method="post">
      > <p>Question 1:
      > <p><textarea name="reply01" cols="40" rows="5"></textarea>
      > <p>Question 2:
      > <p><textarea name="reply02" cols="40" rows="5"></textarea>
      > <p>Question 3:
      > <p><textarea name="reply03" cols="40" rows="5"></textarea>
      > ... etc ...
      > <p><input type="submit" value="Submit answers!">
      > </form>
      >
      > Now, my concern is (since there might be quite a lot of data filled in),
      > if e.g. the internet-connection for some reason is broken
      > at the moment when the user clicks the submit-button,
      > there is a risk they will lose all the text and would have to re-type it,
      > which I would like to avoid, of course.
      >
      > How can I best solve this issue?
      >
      > Ideally, I would like to store the info on their local C: drive
      > before submitting, and automatically retrieve the text if they
      > later return to the page, but I guess that's not possible from
      > an html doc, right?
      >
      > If so, any other suggestions how to resolve this issue?
      >
      > TIA,[/color]


      Comment

      • grz02

        #4
        Re: Save html-forms data to local disk?

        Thanks for hint, seems like cookie could do the trick then...

        Unfortunately, I dont have much experience w client-side scripting,
        could someone please provide or point me to some sample-code
        I could elaborate on here?

        Thanks,


        "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message news:<GOidncrs7 _1eLK_dRVn-vA@comcast.com> ...[color=blue]
        > Trying saving the data into the cookie using Javascript.[/color]

        Comment

        • grz02

          #5
          Re: Save html-forms data to local disk?

          Found some very helpful code here:

          so that problem is basically solved now.

          But just realized I have a follow-up Question:

          By experiment, it seems if I have two different
          html-docs in the same local directory, say c:\dir
          they will share the same cookie-string.

          But if I have two html-docs in different local directories,
          say c:\dir1 and c:\dir2 , they will have different cookie-strings
          stored independently.

          So the Question now is:

          Is there any way to define a "global" cookie that will
          be shared by all documents stored on the local drive,
          regardless of the different directory-paths?

          And where can I find some documentation that describes
          such implementationa l details?

          Thanks,

          Comment

          • Chung Leong

            #6
            Re: Save html-forms data to local disk?

            You can set the domain of the cookie. Try this cookie API. Can't remember
            where I got it from...

            <SCRIPT LANGUAGE="JavaS cript">
            <!--

            // name - name of the cookie
            // value - value of the cookie
            // [expires] - expiration date of the cookie (defaults to end of current
            session)
            // [path] - path for which the cookie is valid (defaults to path of calling
            document)
            // [domain] - domain for which the cookie is valid (defaults to domain of
            calling document)
            // [secure] - Boolean value indicating if the cookie transmission requires a
            secure transmission
            // * an argument defaults when it is assigned null as a placeholder
            // * a null placeholder is not required for trailing omitted arguments
            function setCookie(name, value, expires, path, domain, secure) {
            var curCookie = name + "=" + escape(value) +
            ((expires) ? "; expires=" + expires.toGMTSt ring() : "") +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            ((secure) ? "; secure" : "");
            document.cookie = curCookie;
            }

            // name - name of the desired cookie
            // * return string containing value of specified cookie or null if cookie
            does not exist
            function getCookie(name) {
            var dc = document.cookie ;
            var prefix = name + "=";
            var begin = dc.indexOf("; " + prefix);
            if (begin == -1) {
            begin = dc.indexOf(pref ix);
            if (begin != 0) return null;
            } else
            begin += 2;
            var end = document.cookie .indexOf(";", begin);
            if (end == -1)
            end = dc.length;
            return unescape(dc.sub string(begin + prefix.length, end));
            }

            // name - name of the cookie
            // [path] - path of the cookie (must be same as path used to create cookie)
            // [domain] - domain of the cookie (must be same as domain used to create
            cookie)
            // * path and domain default if assigned null or omitted if no explicit
            argument proceeds
            function deleteCookie(na me, path, domain) {
            if (getCookie(name )) {
            document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
            }
            }

            // date - any instance of the Date object
            // * hand all instances of the Date object to this function for "repairs"
            function fixDate(date) {
            var base = new Date(0);
            var skew = base.getTime();
            if (skew > 0)
            date.setTime(da te.getTime() - skew);
            }

            // -->
            </SCRIPT>


            Uzytkownik "grz02" <grz01@spray.se > napisal w wiadomosci
            news:1641ee43.0 402181458.76203 418@posting.goo gle.com...[color=blue]
            > Found some very helpful code here:
            > http://www.echoecho.com/jscookies02.htm
            > so that problem is basically solved now.
            >
            > But just realized I have a follow-up Question:
            >
            > By experiment, it seems if I have two different
            > html-docs in the same local directory, say c:\dir
            > they will share the same cookie-string.
            >
            > But if I have two html-docs in different local directories,
            > say c:\dir1 and c:\dir2 , they will have different cookie-strings
            > stored independently.
            >
            > So the Question now is:
            >
            > Is there any way to define a "global" cookie that will
            > be shared by all documents stored on the local drive,
            > regardless of the different directory-paths?
            >
            > And where can I find some documentation that describes
            > such implementationa l details?
            >
            > Thanks,[/color]


            Comment

            Working...