<% Flag = request.form("Flag") Select Case Flag Case 0 Flag = Flag + 1 %>
UserID
Password:
   
<% Case 1 UserID = request.form("userid") Password = request.form("password") ' **** be sure to change "admin" and "password" ' **** to your choice of userid and password If UserID <> "admin" OR Password <> "sherida" then response.write "" response.write "Invalid login. Please try again." Else set conn = server.createobject("adodb.connection") ' BEGIN DSN-less connection - comment out or delete if using a DSN DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("guestbook.mdb") conn.Open DSNtemp ' END DSN-less connection - uncomment the next line if using DSN! ' conn.open "guestbook" sqlstmt = "SELECT * from Guestbook Order by PostDate Desc" Set RS = conn.execute(sqlstmt) If rs.eof then response.write "
There are no records in the database" response.write "
Please check back later
" response.end End If response.write "" response.write "" response.write "" Do while not rs.eof ' The database has an autonumber field set as ' the primary key, so we will use that field ' to specify which record we want to modify ID = rs("ID") Name = rs("Name") City = rs("City") Country = rs("Country") %> <% rs.MoveNext loop %> <% End If Case 2 If IsEmpty(request.form("ID")) then response.write "" response.write "Oops! You have to check a " response.write "box for this to work!" response.write "
Please hit your Back" response.write " button and try again." response.end End If set rs = nothing ID = request.form("ID") UserID = request.form("UserID") Password = request.form("Password") set conn = server.createobject("adodb.connection") ' AS ABOVE, change path to guestbook if needed or delete ' the dsn-less connection and use a DSN DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("guestbook.mdb") conn.Open DSNtemp For each record in request("ID") sqlstmt = "DELETE * from Guestbook WHERE ID=" & record Set RS = conn.execute(sqlstmt) Next If err.number>0 then response.write "VBScript Errors Occured:" & "

" response.write "Error Number=" & err.number & "

" response.write "Error Descr.=" & err.description & "

" response.write "Help Context=" & err.helpcontext & "

" response.write "Help Path=" & err.helppath & "

" response.write "Native Error=" & err.nativeerror & "

" response.write "Source=" & err.source & "

" response.write "SQLState=" & err.sqlstate & "

" end if IF conn.errors.count> 0 then response.write "Database Errors Occured" & "

" response.write SQLstmt & "

" for counter= 0 to conn.errors.count response.write "Error #" & conn.errors(counter).number & "

" response.write "Error desc. -> " & conn.errors(counter).description & "

" next else response.write "" response.write "The record has been deleted." response.write "
" response.write "" response.write "" response.write "" response.write "" response.write "" end if End Select set rs = nothing set conn = nothing %>

" response.write "" response.write "Delete Records
<%= Name %> <%= City %> <%= Country %>