Using ASP to build website forum DIY-6

Source: Internet
Author: User
Tags date sql
When the link to the corresponding article is clicked, enter the processing page of this article managearticle.asp:
%
Articleid=request ("ArticleID")
Boardid=request ("Boardid")
If session ("Beenthere") >boardidthen Response.Redirect "Forums.asp"
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 = "Query article by ID"
ReDim param (0)
Param (0) = CLng (ArticleID)//NOTE: CLng can not be ignored
Set rs = cmd. Execute (, param)
Author=rs ("Author id")
Title=rs ("title")
Data=rs ("date")
Rate=rs ("recommended degree")
Boardid=rs ("Kanban id")
Topicid=rs ("Subject ID")
Boardname=rs ("Kanban name")
Topicname=rs ("Subject name")
Content=rs ("content")
Content=replace (Content,vbcrlf, "</p> p>")
Content= "p>" & content& "/p>"
Set cmd=nothing
%>
html>
head>
title>untitled document</title>
"Meta http-equiv=" Content-type "content=" text/html; charset=gb2312 ">
/head>
Body bgcolor= "#E9E9E4"
Table width= "89%" border= "0" cellspacing= "0" cellpadding= "0" align= "center"
TR bgcolor= "#CCCCCC"
td> Author: Font color= "#FF3366" ><a href= "qauthor.asp?author=<%=author%>" ><%=author%> (/a></font>) Date of publication: "Font color=" #FF 3333 "> <%=data%>/font>
Kanban: Font color= "#FF3333" ><a href= "qboard.asp?boardid=<%=boardid%>" ><%=boardname%></a></font> Board main recommended: "Font color=" # FF3333 "> #rate # </font>/td>
/tr>
TR bgcolor= "#CCCCCC"
td> title: Font color= "#FF3333" > <%=title%>
Subject: "A href=" qtopic.asp?topicid= <%=topicid%> ">%=topicname%></a>/font><
/tr>
TR valign= "Top"
td>
hr>
Font color= "#FF3366" > article content:/font>< br>
br>
Font color=blue><%response.writecontent%></font>
br>
hr>
/td>
/tr>
TR valign= "Top"
Form method= "POST" action= "manageresult.asp"
TD height= "18"
Table width= "100%" border= "1" cellspacing= "1" cellpadding= "1"
tr>
TD Width= "29%"
Div align= "Right"
Input type= "hidden" name= "Boardid" value= "%=boardid%>"
Input type= "hidden" name= "TopicID" value= "%=topicid%>"
Input type= "hidden" name= "ArticleID" value= "%=articleid%>"
Article Processing:/div>
/td>
"TD width=" 12% "bordercolor=" "#006666" > delete:
Input type= "Radio" name= "Manage" value=1>
/td>
The TD width= "30%" bordercolor= "#006666" is published:
Input type= "Radio" name= "Manage" value=2>
Recommended Grade
Select Name= "Select"
Option value= "1" >1 </option>
Option value= "2" >2 </option>
Option value= "3" selected>3 </option>
Option value= "4" >4 </option>
Option value= "5" >5 </option>
/select>
/td>
The TD width= "20%" bordercolor= "#006666" to be processed later:
Input type= "Radio" name= "Manage" value=3>
/td>
TD Width= "9%"
Input type= "Submit" name= "Submit" value= "OK"
/td>
/tr>
/table>
/td>
/form>
/tr>
/table>
/body>
/html>
%
Set rs=nothing
Conn.close
Set conn=nothing
%>
Note: This page and the article display module in the article.asp is basically the same, just more than a moderator to deal with the form, here is not much to say.
Below, according to the moderator of the process, repair the corresponding part of the database
%response.buffer=true%>
html>
head>
The title> article deals with the/title>
"Meta http-equiv=" Content-type "content=" text/html; charset=gb2312 ">
/head>
Body bgcolor= "#E9E9E4"
%
Articleid=request ("ArticleID")
Boardid=request ("Boardid")
Topicid=request ("TopicID")
Manage=request ("Manage")
' Accept form Contents
Response.Write Manage ' Display moderator ID
If session ("Beenthere") >boardidthen Response.Redirect "Forums.asp"
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open "Driver={microsoft accessdriver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")
According to the actions of the moderator in the previous page, the following processing is appropriate.
If CLng (Request ("Manage")) =1 Then
Sql= "Delete from content table where id=" & ArticleID
Conn.execute SQL
Response.Write "The h1> article has been deleted Response.Write "A Href=>back </a>"
ElseIf CLng (Request ("Manage")) =2then
sql= "Update content table set published =true whereid=" & ArticleID
Conn.execute SQL
sql= "Update topic table Set article number = article number +1where id=" & TopicID
Conn.execute SQL
Response.Write "The h1> article has been published Response.Write "A Href=>back </a>"
Else
Response.Clear
Response.Redirect "boardmanager.asp?boardid=" & boarded
End If
%>
/body>
/html>
%
Conn.close
Set conn=nothing
%>
After a few steps, all the parts, even if the basic completed, of course, at this time can not be used, put on the stage. If you want to be able to get out of the words, but also in the layout, client data validation and so on a little more effort. But that is the content of HTML, and ASP not much relationship, here I will not say more.

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.