Oh no, not again! Refresh button enters data again

Results 1 to 5 of 5

Thread: Oh no, not again! Refresh button enters data again

  1. #1
    lorddog Guest

    Default Oh no, not again! Refresh button enters data again

    I have an asp page that posts to itself and gets values from a form and enter it into db. Everything is fine but I was messing around and hit refresh and the old data was entered in again!?!<BR>I need someway to detect difference between refresh and my enter button. Is this an dumb mistake on my part that adv prog&#039s know?<BR>Doug

  2. #2
    Join Date
    Dec 1969

    Default RE: Oh no, not again! Refresh button enters data a

    You could do a check on the value of the button.<BR><BR>before you add:<BR><BR>if (Request.Form("cmdButton") == "Enter")<BR>....<BR><BR>(if you defined your button as:<BR>&#060;input type=submit id=cmdButton name=cmdButton value="Enter" ...&#062;<BR><BR>Bart.

  3. #3
    lorddog Guest

    Default yikes, oh yeah

    yeah thats what I was doing <BR><BR>btnFAction = Request.Form("button")<BR>If (btnFAction) Then<BR> ...statements to insert new record<BR>End If<BR><BR>and in the form it is<BR><BR>&#060;Input Type=&#039Hidden&#039 name=&#039button&#039 value=&#039true&#039&#062;<BR><BR>is it because I used a hidden field and should use the enter button instead? That&#039s probably it. I&#039ll try that. I&#039ll name my button and do the check against it instead. Doug

  4. #4
    lorddog Guest

    Default nope still doing it

    I moved my check against the enter button (submit button) and it still enters the transaction on refresh. Am I missing something this seems major wrong. Doug

  5. #5
    Join Date
    Dec 1969

    Default RE: nope still doing it

    Nothing is major wrong. In fact, your browser and script are doing exactly what you have told it to do.<BR><BR>You can do a few things to correct this. <BR><BR>You can play with expiring the contents of the page immediately, so that the user receives a warning about the data expiring, but you still run the risk of reposting.<BR><BR>You can write a cookie to the browser when the data is written to the database, such that if the user tries to enter that same data again, the script would reject it (I would use a hash of all of the data, so that the user could enter &#039other&#039 records and it would still work). <BR><BR>You could use a session variable to track that the user has already written this record (but I do not recommend using session vars).<BR><BR>You could use the data itself to insure that duplicate records are not allowed in the database.<BR><BR>

Posting Permissions

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