The article publishing module has only two pages, one is the submit.asp used to provide input forms, and one is the subresult.asp for processing form input. The front page is very simple, basically is an HTML form, there is nothing to talk about, the following look at the content of subresult.asp:
< html>
< head>
< title> published articles </title>
< meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
< body bgcolor= "#FFFFFF" >
<%
Author=request ("author")
Password=request ("password")
Topicid=request ("TopicID")
Boardid=request ("Boardid")
Content=request ("content")
Title=request ("title")
This section takes out the table submitted in submit.asp but the contents are placed in the corresponding variable.
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")
Set cmd = Server.CreateObject ("Adodb.command")
Set cmd. ActiveConnection = conn
' Query if the author already exists
Cmd.commandtext = "SELECT * from author table where id= '" & Author & "'"
Set rs = cmd. Execute ()
' Check Permissions
If rs.eof or Rs.bof then
Response.Write "< h3> you have not yet registered, please < a href=register.htm> registration </a> later in to publish articles
Response.Write "</body>
Response.End
End If
If password< > rs ("password") then
Response.Write "< h2> password error, please check that the password is correct
Response.Write "</body>
Response.End
End If
This section is the author's permission to check, for the account does not exist or password error to make the appropriate error handling. Here you can see the usage of Response.End, which is used to end the current ASP script. Combined with an If statement, you can handle the expected errors in the program. In a good Web application, error handling is essential.
' Change the single quotation marks in the data to two single quotes and precede them with single quotes
Function sqlstr (data)
Sqlstr = "'" & Replace (data, "'", "" ") &" "
End Function
' Write to the database
sql = "Insert into content table (Kanban ID, subject ID, author ID, title, content) Values ("
sql = SQL & Sqlstr (topicid) & ","
sql = SQL & Sqlstr (boardid) & ","
sql = SQL & Sqlstr (author) & ","
sql = SQL & Sqlstr (title) & ","
sql = SQL & SQLSTR (content) & ")"
Conn. Execute SQL
%>
< h2> articles have been sent to the database, and when the board is reviewed you can see the < h2>
</body>
Here, the article has been saved in the database. However, it can not be displayed immediately, but also need the approval of the owner to do. Next, take a look at the content of the Management section of the Forum.