SoFunction
Updated on 2025-04-13

Page 6/8 of the commonly used function library collection in asp production


(3) Change the single quotes in the information to two single quotes, and add single quotes before and after.

   
  Function SqlStr( data ) 
  SqlStr = "'" & Replace( data,"'", "''" ) & "'" 
  End Function 
'Write to the database
sql = "Insert Into Content Table (Kanban id, topic 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) & ")" 
   sql 
  %> 
< h2> The article has been sent to the database. After reviewing the board owner, you can see <h2>
  < /body> 
  < /html> 

At this point, the article has been saved in the database. However, it cannot be displayed immediately, and it also requires the moderator's approval. Let’s take a look at the content of the management part of the forum.

   
4. The management part of the forum

This is the core of our forum, but there is nothing special about it. Still those old things: form processing, database query, and organically combining them with ASP. After entering the article review mode (the board processing mentioned above), the most important content should be to verify the identity of the moderator. Let’s take a look at the moderator’s login page:

   
  < % 
  boardid=request("boardid") 

   
(Note: the boardid is passed by the connection entering this page, and is the ID of the board that needs to be processed on the board. Only through it can you know which board is processed on the board.)
  Set conn = ("") 

   "driver={Microsoft AccessDriver (*.mdb)};dbq=" & ("") 
  Set cmd = ("") 
  Set  = conn 
= "Board Master Password Query"
  ReDim param(0) 
param(0)= CLng(boardid)//Note: CLng cannot be ignored
  Set rs = ( ,param ) 
boardmanager=rs("board owner")
  set cmd=nothing 
  %> 
  < html> 
  < head> 
  < title>Untitled Document< /title> 
  < meta http-equiv="Content-Type"content="text/html; charset=GB2312"> 
  < /head> 
  < body bgcolor="#FFFFFF"> 
< p>Only the board owner < %=boardmanager%> can enter this place </p>
< p> Please enter the verification password, and in order to maintain authentication, please open the browser's cookies. </p>
  < form method="post" action=""> 
  < input type="password" name="password"> 
  < input type="hidden" name="boardid"value=< %=boardid%>> 
< input type="submit" name="Submit"value="OK">
  < /form> 

   
Note: This page is only for login. After obtaining the password entered by Banzhu, it cannot be verified, but instead puts the verification work on the next page. In fact, password input and verification can be done in one page, but the structure of the program code is a bit troublesome.

   
  < /body> 
  < /html> 
  < % 
  set rs=nothing 
   
  set conn=nothing 
  %> 

Now that I have obtained the moderator ID and the entered password, the following is the verification work. It accepts the content of the form in the file above and performs related processing:

   
  < % 
  =true 

Note: Set the buffer to allow use. Generally speaking, this article should be added to the header of each ASP page, which can improve the performance of the ASP page. After opening the buffer, there are some corresponding special usages in ASP, which will be mentioned later.
Previous page12345678Next pageRead the full text