In answer to your general question, which I will rephrase as:

I've got a form-->CGI scenario; let there be no re-entry of the same data.

There are a number of things to consider.

* What defines an invalid resubmission? Never twice by the same user? Never twice by the same machine/browser? (cookies come into play here) Never twice within 2 seconds /2 minutes / 2 hours? Perhaps one of the submitted fields can't be a duplicate?

Any of the above ideas are the basis for a code-based solution for distinguishing valid submisssions.

* If you do end up having the CGI set a cookie to indicate that this browser has submitted this form you'll run into a number of limitations. Cookies can be deleted due to space considerations. Your cookie won't be set prior to a user being able to click the submit button again (and again, and again).

One idea to help prevent users from clicking a submit button multiple times is to have a javascript function hide the submit button and message the user (Processing...) after the first submission. Your CGI would continue to work as needed.

A working example to put in your HTML:

you can use this Javascript and this code snippet below, using the onsubmit attribute of the form tag.

<script language="JavaScript"> <!-- function submitForm() { document.getElementById('submit').value = "Please Wait..."; document.getElementById('submit').disabled = "disabled"; return true; } //--> </script> <form method="post" action="login.asp" onsubmit="submitForm();"> <input type="text" id="price" name="price"><br> ... <input id="submit" name="submit" type="submit" value="Send data"> </form>

Monks:
Please don't flame me for not addressing this in perl. I'm not aware of any client-side perl and this particular problem needs to be addressed on the client-side.

Cheers

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday


In reply to Re: CGI Cookie by freddo411
in thread CGI Cookie by rupesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.