ASP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.11

hyBook - A Simple Guestbook Application

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13 

ASP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

hyBook - Guestbook Application

Using MS Access Databases

ActiveX Data Object (ADO)

Controlling Response Header Lines

Microsoft Scripting Runtime DLL

Using Cookies

ASP Sessions

ASP Objects

Microsoft Script Debugger

Internet Information Services (IIS)

... Table of Contents

(Continued from previous part...)

Webmaster Administration Page

Whenever you are taking user's input to a database, you have to write an administration page for yourself as the Webmaster to manage those data. The administration page should have the following features:

  • All functions should be password protected.
  • It should be able to locate any record in the table.
  • It should be able to delete any record from the table.
  • It should be able to correct any field in a record.

In hyBook, I wrote the following simple admin page,

<!--#include file='_config.inc'-->
<%
'  comment_admin.asp
'
'  Comment admin page
'  hyBook version 2006.01.01
'  Copyright (c) 2006 by Dr. Herong Yang, http://www.herongyang.com/

   Dim bgDoSubmit, hgRqParam, hgDbParam, hgPgParam
   bgDoSubmit = False
   Set hgRqParam = CreateObject("Scripting.Dictionary")
   Set hgDbParam = CreateObject("Scripting.Dictionary")
   Set hgPgParam = CreateObject("Scripting.Dictionary")

   Dim sgError, sgNotice
   sgError = ""
   sgNotice = ""

   Dim sgPass, sgAdminPass
   sgPass = ""
   sgAdminPass = "ssapnimda"

   Dim bgShowDetail, bgShowList
   bgShowDetail = False
   bgShowList = False

%>
<!--#include file='_template.inc'-->
<%
Sub opening
   dbConnect

'  Checking password
   sgPass = Request.Querystring("Pass")

   If Request.Form("Method") = "Post" Then
      sgPass = Request.Form("Pass")
   End If

   If sgPass = sgAdminPass Then
      bgShowDetail = True
      bgShowList = True
      bgDoSubmit = True
   Else
      sgError = "Invalid password."
   End If

'  Handling submit
   If  bgDoSubmit Then
      doSubmit
   End If
End Sub

Sub outputHeader
   Response.Write("<p class=hy_title>")
   Response.Write(sgPageTitle & " - Admin") 
   Response.Write("</p>")
   Response.Write("<form action=""" _
      & Request.ServerVariables("SCRIPT_NAME") & """ method=post>")
   Response.Write("<input type=hidden name=Method value=Post>")
   Response.Write("<input type=hidden name=Pass value=""" _
      & sgPass & """>")
End Sub

Sub outputBody
   If sgError <> "" Then 
      htmlError(sgError)
      sError = ""
   End If

   If sgNotice <> "" Then 
      htmlNotice(sgNotice)
      sNotice = ""
   End If

   If bgShowDetail Then 
      htmlDetail
   End If
   
   If bgShowList Then 
      htmlList
   End If
End Sub

Sub outputFooter
   Response.Write("</form>")
   ' Do nothing
End Sub

Sub closing
   dbClose
End Sub

(Continued on next part...)

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13 

Dr. Herong Yang, updated in 2005
ASP Tutorials - Herong's Tutorial Notes - hyBook - A Simple Guestbook Application