The previous section has introduced a database connection for article management, and this article will cover the online additions to the article. When you find a good piece of information, and want to put it on your site as soon as possible, if you first think of a quick to do a page, and quickly upload it with FTP, then here these are not necessary, Here you can enter the management page by adding articles, and then directly paste the article copied over it, which is also the focus of this article--the article online Add.
In addition, through the following step-by-step explanation, I believe you can understand the meaning of the HTM code here will not be told.
Create a new ASP file addarticle.asp with the following specific code:
"Insert database connection open File
<!--#include file= "conn.asp"-->
"This program will later be used to verify administrator information, mainly to prevent others from being able to add articles directly without password verification.
<%
If Request.Cookies ("Adminok") = "" Then
Response.Redirect "Login.asp"
End If
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "generator" content= "Microsoft FrontPage 3.0" >
<title> Create articles </title>
<link rel= "stylesheet" type= "Text/css" href= "Style.css" >
<body>
<form method= "POST" action= "savearticle.asp" >
<div align= "center" ><center><table border= "1" cellspacing= "0" width= "80%" bordercolorlight= "#000000" bordercolordark= "#FFFFFF" cellpadding= "0" >
<tr>
<TD width= "100%" bgcolor= "#D0D0D0" height= "M" ><div align= "center" ><center><p><b> Add text Chapter </b></td>
</tr>
<TR align= "center" >
<TD width= "100%" ><table border= "0" cellspacing= "1" width= "100%" >
<tr>
<TD width= "15%" align= "right" height= "a" ><b> article title:</b></td>
<TD width= "85%" height= ">"
"Enter the article title information here
<input type= "text" name= "Txttitle" size= "" class= "Smallinput" maxlength= ">"
</td>
</tr>
<tr>
<TD width= "15%" align= "right" height= "a" ><b> article column:</b></td>
<TD width= "85%" height= ">"
"Open a specified recordset with a Recordset object and select
<select class= "Smallsel" name= "typeID" size= "1" >
<%
Dim Rs,sql,sel
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from Type"
"Set open mode is read only
Rs.Open sql,conn,1,1
"Displays all of the contents of the recordset, where the column name is displayed in the Drop-down menu, and the name of the column is selected here when the article is added.
Do as not rs.eof
Sel= "Selected"
Response.Write "<option" & Sel & "Value=" +cstr (RS ("typeID")) + "' Name=typeid>" +rs ("type") + "</option > "+CHR (10) +CHR
"Displays a record and automatically moves to the next record later.
Rs.movenext
Loop
"Close open recordsets and database connections
Rs.close
Set rs=nothing
Conn.close
%>
</select></td>
</tr>
<tr>
<TD width= "15%" align= "right" valign= "top" ><b> article content:</b></td>
<TD width= "85%" >
The article content add area
<textarea rows= "name=" txtcontent "cols=" class= "Smallarea" ></textarea></td>
</tr>
<tr>
<TD width= "15%" align= "right" valign= "top" height= "></td>"
<TD width= "85%" ></td>
</tr>
</table>
</td>
</tr>
</table>
</center></div><div align= "center" ><center><p><input type= "Submit" value= "Add"
Name= "Cmdok" class= "ButtonFace" > <input type= "reset" value= "clear"
Name= "Cmdcancel" class= "ButtonFace" ></p>
</center></div>
</form>
</body>
At this point, our article to add a page to complete, added the article of course, but also to save the line, so the next section will detail the preservation of the detailed process, you can also understand in the ASP code is how to do database operations.