how to avoid multiple submit button click??????

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

    how to avoid multiple submit button click??????

    i have one form on which the data is stored in database and suppose the
    user clicks the back button of browser and again click on submit button
    then the data will be saved in database again.

    so how can i solve this problem????

    thxs for help in advance

  • Micha³ Wo¼niak

    #2
    Re: how to avoid multiple submit button click??????

    One quick glance of an experienced eye allowed to understand the blurred
    and almost unreadable vishal's handwriting:
    [color=blue]
    > i have one form on which the data is stored in database and suppose the
    > user clicks the back button of browser and again click on submit button
    > then the data will be saved in database again.
    >
    > so how can i solve this problem????
    >
    > thxs for help in advance[/color]

    <H1 style='color:re d; font-weight:bold; font-style:italic;
    font-decoration:unde rline; background: green'>Now don't you even TRY to
    click this button twice!</H1>
    <INPUT type='submit' ...>

    ;)

    Seriously, you could simply check if the data has been already written,
    or generate a random ID in a hidden input, so that you know if data has
    already been written.

    Cheers
    Mike

    Comment

    • Wyzcrak

      #3
      Re: how to avoid multiple submit button click??????


      vishal Wrote:[color=blue]
      > so how can i solve this problem????[/color]
      Just an idea: put a key in the user's session which must be present t
      submit the form.

      You could put this key in the session when the page with the submi
      button is served from the server to the browser. When the form'
      ACTION is processed, you could clear this key from the user's session.
      If the key doesn't exist in the user session to begin with, you don'
      process the POST.

      If the user presses the brower's back button, the key would not b
      present in their session, right? So the POST wouldn't be processed

      --
      Wyzcrak:: Posted from Tactical Gamer - http://www.TacticalGamer.com :

      Comment

      • Colin McKinnon

        #4
        Re: how to avoid multiple submit button click??????

        Micha? Wo?niak wrote:
        [color=blue]
        > One quick glance of an experienced eye allowed to understand the blurred
        > and almost unreadable vishal's handwriting:
        >[color=green]
        >> i have one form on which the data is stored in database and suppose the
        >> user clicks the back button of browser and again click on submit button
        >> then the data will be saved in database again.
        >>
        >> so how can i solve this problem????
        >>
        >> thxs for help in advance[/color]
        >
        > <H1 style='color:re d; font-weight:bold; font-style:italic;
        > font-decoration:unde rline; background: green'>Now don't you even TRY to
        > click this button twice!</H1>
        > <INPUT type='submit' ...>
        >[/color]

        <input type'button' value='Submit' id='notReallyAS ubmit'
        onclick='if (this.form.onsu bmit()) {
        this.form.submi t();
        this.enabled=fa lse;
        }'>

        Maybe?

        C.

        Comment

        • Michael Winter

          #5
          Re: how to avoid multiple submit button click??????

          On 08/04/2005 17:04, Colin McKinnon wrote:

          [snip]
          [color=blue]
          > <input type'button' value='Submit' id='notReallyAS ubmit'
          > onclick='if (this.form.onsu bmit()) {
          > this.form.submi t();
          > this.enabled=fa lse;
          > }'>
          >
          > Maybe?[/color]

          And if client-side scripting is unavailable? No, checking if data has
          already been sent is much better, more reliable approach.

          Mike

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          • Peter Fox

            #6
            Re: how to avoid multiple submit button click??????

            Following on from vishal's message. . .[color=blue]
            >i have one form on which the data is stored in database and suppose the
            >user clicks the back button of browser and again click on submit button
            >then the data will be saved in database again.
            >
            >so how can i solve this problem????
            >
            >thxs for help in advance
            >[/color]
            With many of my pages is do a quick check on the referring page. This
            stops simple back-button clicking and bookmarking which may be
            inappropriate.
            $_SERVER['HTTP_REFERER']. But read the manual for caveats.




            --
            PETER FOX Not the same since the submarine business went under
            peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
            2 Tees Close, Witham, Essex.
            Gravity beer in Essex <http://www.eminent.dem on.co.uk>

            Comment

            • BKDotCom

              #7
              Re: how to avoid multiple submit button click??????

              I still like to replace submit buttons with disabled "please wait"
              buttons on the client side
              I don't rely on this, but it's good UI.

              <FORM onSubmit="pleas e_wait();">

              or onClick/onChange,etc = "please_wait(th is.form);"

              function please_wait(wha tform)
              {
              // sets value of all submit buttons to please wait and disables them
              // whatform is optional
              for ( f=0; f<document.form s.length; f++ )
              {
              var form = document.forms[f];
              for ( i=0; i<form.length; i++ )
              {
              if ( typeof form.elements[i].type != 'undefined' &&
              form.elements[i].type == 'submit' )
              {
              form.elements[i].disabled = true;
              form.elements[i].value = 'Please Wait...';
              }
              }
              }
              // now submit form if specified
              if ( typeof whatform != 'undefined' )
              whatform.submit ();
              }

              Comment

              • Kenneth Downs

                #8
                Re: how to avoid multiple submit button click??????

                vishal wrote:
                [color=blue]
                > i have one form on which the data is stored in database and suppose the
                > user clicks the back button of browser and again click on submit button
                > then the data will be saved in database again.
                >
                > so how can i solve this problem????
                >
                > thxs for help in advance[/color]

                Does your database table have a unique constraint? If not, choose which
                column or columns should always be unique and put on a constraint. Any
                approach which is not in the database itself is subject to failure.

                --
                Kenneth Downs
                Secure Data Software, Inc.
                (Ken)nneth@(Sec )ure(Dat)a(.com )

                Comment

                • Geoff Berrow

                  #9
                  Re: how to avoid multiple submit button click??????

                  I noticed that Message-ID: <ruiji2-scj.ln1@pluto.d ownsfam.net> from
                  Kenneth Downs contained the following:
                  [color=blue][color=green]
                  >> thxs for help in advance[/color]
                  >
                  >Does your database table have a unique constraint? If not, choose which
                  >column or columns should always be unique and put on a constraint. Any
                  >approach which is not in the database itself is subject to failure.[/color]

                  What is needed is not a unique constraint on the individual columns (for
                  example last_name will not be unique) but a unique constraint on the
                  tuple excluding the primary key. Does MySQL do this?

                  --
                  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

                  Working...