ASP Advanced Tutorial Ⅵ: Guest Book Delete message online

Source: Internet
Author: User
Tags include

Remember what we did in chapter three to delete the message? In order to delete the message that smeared on your face, the only way we could use it was to find and delete it directly on the message database. (and even after the seventh chapter, we can only lock the first through the "Message management" password verification, and then download the entire message database, delete changes later upload. Oh, my God! You can't guarantee that when you see a message that you don't like, it's when you're using the server that has your guest book. If one day you are on a business trip, or you are using the computer simply does not install what upload software ... Isn't it? You got nothing to do? So we can only look raw space laissez-faire some "good people" to disrupt our guest book?
We certainly do not tolerate letting "good people" come to our guest book for wanton smear, so in this chapter I will tell you how to add the function of the message deletion to our guestbook.
Since you want to add online message deletion function, the message Editor page can not be, so I have introduced in the previous chapters of the Message Display page program page2.asp and self2.asp slightly modified, in fact, just in each display message to add a "delete message" button. But one thing we have to be clear is that the "delete message" button on each message should be valid only for this message, and not for the rest of the message. So we can add the following statement in the appropriate position in the self2.asp and save it as editself.asp, which is the program used to define the message display format in the message editing interface.
Tab = tab & < tr>< td>< A href= "delete.asp?id=" & RS ("ID") & "" > "
Tab = tab & < b> Delete message </b> "&" </td></tr> "
' RS (" id ") refers to the record of the ID field. RS ("ID") should be fully written "Rs." Fields ("ID"). Value "Because fields is the default property of the Recordset object, value is the default property of the Field object, so we can abbreviate to Rs (" ID ").

Similarly, we simply replace the <!--#include file= "self2.asp"--> above the Page2.asp program with the <!--#include file= "editself2.asp"--> This is to delete the Message page message processing program editpage2.asp.
After completing the message editing page, let's take a further step to learn about removing the message handler (delete.asp).
<!--#include file= "adovbs.inc"
<%
Set conn = Server.CreateObject ("ADODB. Connection ")
DBPath = Server.MapPath (" Book2.mdb ")
Conn. Open driver={microsoft Access Driver (*.mdb)};d bq= "& dbpath
sql =" DELETE from guestbook WHERE (ID = "& Reque St. QueryString ("id") & ")" Set RS = conn. Execute (SQL)
%>
' because the message record we want to delete is a message record that corresponds to the ID of the message database with the "Delete message" button, so we are here through "& Request.QueryString" (" ID "&" to get the ID of the message for the current operation. The above SQL command indicates that the deletion of the ID number in the message database is consistent with the ID of the current operation's message.

<%
Sub Delaysecond (delayseconds)
Seccount = 0
SEC2 = 0
While Seccount < Delayseconds + 1
SEC1 = Second (Time ())
If Sec1 <> Sec2 Then
SEC2 = Second (Time ())
Seccount = Seccount + 1
End If
Wend
End Sub
%>
<% Delaysecond (2)%>
' Delay 2 seconds after deleting message operation.
<% Response.Redirect ("page2.asp")%>
' Delete the message and direct the client browser to the ' View message ' page.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.