To read the article online, visit http://www.4GuysFromRolla.com/webtech/012600-1.2.shtml

Rewiring the Back Button, Part 2

By TJ Sylvester


  • Read Part 1


  • In Part 1 we discussed how to create the first two pages of the system. In this part, we'll look at creating the last two pages!

    I think you'll find that the third and fourth pages are fairly simple. The third page, redirect.asp is responsible for handling any form processing. For example, if you have your users enter a value in form.asp that needs to be inserted into a database, in the third page, redirect.asp, this processing needs to occur. redirect.asp also redirects the user to the confirmation page after any needed form processing is completed. A small note, the redirect.asp page is set to refresh to confirmation.asp in one second, which is a small delay. The reason behind this: Internet Explorer. If you set the time to zero seconds, it will ignore redirect.asp and head straight back to form.asp.

    <%@ Language=VBScript %>
    <%
    Response.Buffer = True
    
    ' checks for empty session variable, 
    ' otherwise display the page which refreshes to confirmcation.asp
    if isEmpty(Session("GoForward")) then
    	Response.Redirect "default.asp"
    else
        'Perform needed form processing here
        '(i.e., database entries)
    %>
    
    <html>
    <head>
    	<META HTTP-EQUIV="Refresh" CONTENT="1;URL=confirmation.asp">
    </head>
    <body>
      The form is being processed.  Please be patient.
    </body>
    </html>
    

    The fourth page (confirmation.asp) will provide a confirmation of the form submission. This page simply displays a Thank You message, or some sort of confirmation.

    <%@ Language=VBScript %>
    <%
    Response.Buffer = True
    
    ' checks for empty session variable,
    ' and redirects to main page
    if isEmpty(Session("GoForward")) then
    	Response.Redirect "default.asp"
    else
    ' if session variable is present, display this code
    %>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <table width="400">
    	<tr><td>
          <p>
          Thank you. Your request has been submitted to the IT 
          Department. Your confirmation number is <b>xxx</b>. 
          Please refer to this number when contacting the IT Department. 
          You can view the status of your request by using the 
          status page.</p>
    	</td></tr>
    </table>
    
    </BODY>
    </HTML>
    <%
    end if
    
    ' this will kill the session variable
    Session.Abandon
    
    ' You could also use:
    ' Session("GoForward") = ""
    %>
    

    Now that you have the code, try it out. Open default.asp and click the form link. On the form.asp page, click submit. If you noticed, the form processes itself, then redirects to redirect.asp.

    The purpose of redirect.asp is to create an HTML page for the back button to hit while a META tag to refresh to confirmation.asp. Using the META tag to refresh to another page will load a fresh instance of that page.

    Confirmation.asp now checks for the session variable. If it is present, it will display the confirmation and the kill the session variable. If a user clicks the back button, redirect.asp is loaded up which will send them directly back to confirmation.asp. This time, however, the session variable is empty and we are redirected to default.asp.

    Happy Programming!

  • Read Part 1


    Attachments:

  • Try out the example!
  • Download the source code in text format


  • Article Information
    Article Title: Rewiring the Back Button, Part 2
    Article Author: TJ Sylvester
    Published Date: Wednesday, January 26, 2000
    Article URL: http://www.4GuysFromRolla.com/webtech/012600-1.2.shtml


    Copyright 2017 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers