Using ASP to create personalized forum (next)

Source: Internet
Author: User
Tags end sql query reset version client
4, the Forum Management Section

This is the heart of our forum, but it is nothing special to realize. Or those old things: Form processing, database query, in the use of ASP to their organic combination. When entering the article review mode (referred to the Board processing), the most important content, should be the identity of the moderator to verify. below to see moderator landing page:

<%

Boardid=request ("Boardid")

(Note: The Boardid is passed through the connection to this page and is the ID of the kanban to be handled by the board.) It is through it to know that the board is dealing with the board. )

Set conn = erver. CreateObject ("ADODB.") Connection ")

Conn. Open "Driver={microsoft accessdriver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")

Set cmd = Server.CreateObject ("Adodb.command")

Set cmd. ActiveConnection = conn

Cmd.commandtext = "board Master password Query"

ReDim param (0)

Param (0) = CLng (Boardid)//NOTE: CLng can not be ignored

Set rs = cmd. Execute (, param)

Boardmanager=rs ("board Master")

Set cmd=nothing

%>



<title>untitled document</title>

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">


<body bgcolor= "#FFFFFF" >

<p> only Board Master <%=boardmanager%> can enter this place </p>

<p> Please enter a validation password and, in order to remain authenticated, open the browser's cookies. </p>

<form method= "POST" action= "managerloginrest.asp" >

<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 used for landing, it gets the password entered by the moderator, and can not be validated, but the validation of the work on the next page. In fact, the work of password input and validation can be done in one page, but the structure of the program code is a bit cumbersome.

</body>


<%

Set rs=nothing

Conn.close

Set conn=nothing

%>

Now get the moderator ID and entered the password, the following is the work of validation managerloginrest.asp, it accepts the above file form content, and related processing:

<%

Response.buffer=true

Note: Set the buffer to allow use. In general, this should be added to the header of each ASP page, which can improve the performance of ASP pages. After opening the buffer, there are some special usages in the ASP, which are mentioned later.

Boardid=request ("Boardid")

Password=request ("password")

Set conn = Server.CreateObject ("ADODB. Connection ")

Conn. Open "Driver={microsoft accessdriver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")

Set cmd = Server.CreateObject ("Adodb.command")

Set cmd. ActiveConnection = conn

Cmd.commandtext = "board Master password Query"

ReDim param (0) ' statement

Param (0) = CLng (Boardid)//NOTE: CLng can not be ignored

Set rs = cmd. Execute (, param)

Boardmanager=rs ("board Master")

If password<> rs ("password") then%>



<title> Authentication </title>

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">


<body bgcolor= "#FFFFFF" >

Bad password

</body>


<%

Else

Session ("Beenthere") =boarded

Note: Use session to maintain authentication to moderators, which requires that the cookie for the client browser be opened. Because the session is implemented through cookies. Here, the Kanban ID is assigned to the session variable Beenthere, indicating that the moderator master has passed the authentication. In each subsequent version of the page, check to see if the Beenthere and the corresponding version ID match.

Url= "boardmanager.asp?boardid=" & Boardid

Response.Redirect URL

Add: Beginner ASP Always for Response.Redirect This method is confused, repeatedly with uncomfortable, now I come to tell you some skills. Before you can use it, you must use the Response.buffer=true to make the ASP page work with buffers. At this point, before the ASP is interpreted as an HTML program code, it is placed in a buffer instead of being sent directly to the client browser. There is also a need to know that before using Response.Redirect, no actual HTML program code can be sent to the client browser, or there will be an error. Of course there are workarounds, if the HTML program code is explained before Response.Redirect, you can use the Response.Clear method to clear the buffer, and then you can use it to reset.

End If

%>

Note: The following is the target of the reset after the authentication is passed: boardmanager.asp. It will list all the articles that have not been processed.

<%

Boardid=request ("Boardid")

If session ("Beenthere") <>boardidthen Response.Redirect "Forums.asp"

Note: This is the test moderator identity, because the previous cookie in the owner's browser has been marked, now we can through the seesion to identify the moderator. If the mark does not match, it will return to the first landing page via Response.Redirect. If the moderator browser's cookie is not open, then the value of Seesion ("Beenthere") will be empty, also cannot enter this page.

Set conn = Server.CreateObject ("ADODB. Connection ")

Conn. Open "Driver={microsoft accessdriver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")

Set cmd = Server.CreateObject ("Adodb.command")

Set cmd. ActiveConnection = conn

Sql= "SELECT name from Kanban list whereid=" & Boardid

Set Rs=conn.execute (SQL)

Boardname=rs ("name")

cmd.commandtext= "List of unpublished articles"

ReDim param (0)

Param (0) = CLng (Boardid)//NOTE: CLng can not be ignored

Set rs = cmd. Execute (, param)

Set cmd=nothing

%>



<title> Edition Processing </title>

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">


<body bgcolor= "#FFFFFF" >

&LT;H1 align= "Center" ><%=boardname%> Edition management

<%

If rs.eof or Rs.bof then Response.Write "<H2> there is no article to process
Response.End

%>

Note: If no new articles are posted by netizens, this gives the appropriate hints and ends the display of this page with Response.End.

<table width= "90%" border= "0" cellspacing= "0" cellpadding= "0" align= "center" >

<tr Bgcol



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.