Click to See Complete Forum and Search --> : Forcing Redirect when Back Button is pressed


Brachole
06-04-2010, 10:28 AM
I have 4 pages in my application:


Page1.asp (form page using the POST Method)

Page2.asp (Insert to Database script + Redirect to Page3.asp)

Page3.asp (Page displaying the the confirmation of insertion)


The problem I'm facing is that once on Page3.asp (confirmation page), if the user hits the Back Button, it brings him back to Page1.asp with the form already filled with data previously entered. Eventually, the data can be inserted twice.


Is there a way to redirect the user to say Page4.asp when clicking the back button from Page3.asp?

I tried setting a Session Variable on Page2.asp:

<% Session ("firstvisit")="no" %>

And then use if/else on Page1.asp

<% if Session("firstvisit") = "no" then
Response.Redirect "page4.asp"
end if
%>

Problem is when you click the Browser's Back Button, it doesn't work!

yamaharuss
06-04-2010, 01:39 PM
What I've always done is have page1.asp submit to itself and process everything on the same page

page1.asp

If request(submit) = "submit" then
process form here
redirect(?action=complete)
elseif request(submit) = "complete" then
thank you goes here
else
<form action="?action=submit">
your form goes here
end if

You get the idea (code is all shorthanded of course)