How to avoid submitting the same form twice

Results 1 to 4 of 4

Thread: How to avoid submitting the same form twice

  1. #1
    Join Date
    Dec 1969
    Posts
    47

    Default How to avoid submitting the same form twice

    Hi,<BR>I have three asp files namely, one.asp, two.asp and inter.asp. My default file is one.asp, if the user submits the form one.asp it goes to inter.asp and does all the database opertion and loads two.asp. Now if i press the "Back" button of browser it again calls the form inter.asp and displays the same two.asp (typically one.asp is getting submitted twice). So my browser back button is not working.<BR><BR>How to solve this problem<BR><BR>Thanks in advace<BR>

  2. #2
    Richard L. Guest

    Default RE: How to avoid submitting the same form twice

    If you want to prevent then from *ever* submitting the same data twice, I recommend making one or more fields in your table(s) primary keys and then testing the form data to see if it violates the (those) primary keys prior to submitting. (You don&#039t even have to make primary keys, actually, just check first to see if the record exists already and if so, don&#039t do your database updates). <BR><BR>HTH<BR>Richard

  3. #3
    Vivek Nama Guest

    Default How to avoid submitting the same form twice

    You are probably using client side script in inter.asp to move to two.asp something like <BR>&#060;script language=javascript&#062;<BR>window.location.href= "three.asp"<BR>&#060;/script&#062;<BR>Thus the page inter.asp is processed and an equivalent html page is generated before moving on to two.asp<BR>Naturally now the history object of the browser now has three URLs in order of chronology one.asp, inter.asp, two.asp<BR>Hence the result on pressing the BACK button from two.asp<BR>SOLUTION<BR>You should use response.redirect to move to two.asp post database interaction on inter.asp<BR>(prevents reaching inter.asp on BACK button press from two.asp)<BR>AND<BR>Use a session variable to identify first call within inter.asp as follows<BR>if session("FirstVisitToInterASP")="" then<BR> session("FirstVisitToInterASP")="Visited" <BR> process database interaction<BR>else<BR> Response.Write "You have already been entered"<BR>end if<BR>(prevents reaching inter.asp on resubmmitting from one.asp)

  4. #4
    ActiveALLI Guest

    Default RE: How to avoid submitting the same form twice

    There are i Think two ways of solving this problem .. <BR>1) merge inter.asp and two.asp together .. that is first do the database stuff and then display results or errors on the same page with if statements then the back buton goes to one.asp without any hassle<BR>2) you can put a checker in top of inter.asp, witch checks if you are coming from two.asp and if you are then tells you to go to one.asp with out executeing the code in inter.asp. you can do this by putting:<BR>&#060;% if Request.ServerVariables("HTTP_REFFERER") = "two.asp" then<BR> Response.Redirect("one.asp")<BR> end if %&#062;<BR>at the top of inter.asp.<BR><BR>Hope this helps <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
  •