Building the website News Automatic Publishing System two

Source: Internet
Author: User
Tags date connect microsoft frontpage
(ii) Addition and management of daily news content
When the news was submitted, It is referred to an ASP program called Addnew.asp to deal with the news content. In order to classify and save, in order to show the analysis, every time we submit a piece of news, the following news content Library will be read back, so that we can see whether the news can be successfully joined the database, can also be released to delete news content.
Now let's see how the addnew.asp completes the process.

% @language = "VBScript"%
《%
Response.buffer=true
Response.expires=0

' Save data
Session ("title") =request.form ("title")
Session ("comment") =request.form ("comment")
Session ("Pic") =request.form ("Pic")
Session ("Class_name") =request.form ("Class_name")
Session (' head ') =request.form ("Head")

' The arguments passed are inconsistent with the requirements.
If Request.Form ("title") = "" Then
Response.Redirect "Delete.asp"
End If

If Request.Form ("comment") = "" Then
Response.Redirect "Delete.asp"
End If

If Request.Form ("class_name") = "" Then
Response.Redirect "Delete.asp"
End If


Select Case Request.Form ("class_name")

Case "Market"
Class=1
Case "It News"
class=2
Case "Guangzhou Market"
Class=3
Case "Reservation"
Class=4
Case "Reservation"
Class=4

End Select


' Connect to the database
%》
"The!--#include virtual="/news/data/data.inc "
《%

Set rs = Server.CreateObject ("ADODB.") Recordset ")
Sql= "SELECT * from Data order by news_id ASC"
Rs.Open sql,conn,3,2

' Lookup number
If Rs.bof Then
Reco=0
Else
Rs.movelast
RECO=CLNG (RS ("news_id")) +1
End If

Rs.addnew
RS ("news_id") =reco

If Request.Form ("head") = "yes" then
RS ("News_head") =-1
End If

RS ("News_class") =class
RS ("News_class_name") =request.form ("Class_name")
If Request.Form ("pic") "" "Then
RS ("News_pic") =request.form ("Pic")
RS ("News_title") =request.form ("title") & "(text)"
Else
RS ("News_title") =request.form ("title")
End If



If Request.Form ("head") = "yes" then
RS ("News_head") =-1
End If

Tmpmess=request.form ("comment")
Tmpmess=replace (TMPMESS,CHR (10), "
")
Tmpmess=replace (Tmpmess, "" "," ")
Tmpmess=replace (Tmpmess, "" "," ")"
Tmpmess=replace (Tmpmess, "
","
")
RS ("News_comment") =tmpmess
RS ("News_year") =year (Date)
RS ("News_month") =month (Date)
RS ("News_day") =day (Date)
If Instr (time, afternoon) "0 then"
Tmp=left (Right (time,8), 2) +12
RS ("News_time") =tmp&right (time,6)
Else
RS ("News_time") =tmp&right (time,8)
End If

RS ("News_delete") =0
Rs.update
Rs.close

Response.Redirect "Delete.asp"
%》


The program first judged whether the news submitted by the conditions, such as news headlines can not be empty, and line breaks must be converted to the HTML statement of BR, otherwise can not normally display the format of the news, And here we have a file containing data.inc, its use is mainly used to connect different databases, so the ASP program through the inclusion of this file to specify the data source, then when the change in the use of other databases, only need to change the file, you can easily achieve the switch between different databases, is it very convenient?
The contents of the following Data.inc file.
《%
Set conn = Server.CreateObject ("ADODB. Connection ")
DBPath = Server.MapPath ("/") & "/news/data/data.mdb"
Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & DBPath
%》


It's also worth noting that the values returned by the NT and Windows 98 date-time functions are different. The Win98 is calculated in 24 hours, while NT Server uses 12 hours, plus "Morning" and "PM" to indicate, so a little more should be done.

After processing the program, redirect delete.asp This ASP file, to refresh the news database display, then each submitted a news material, we can immediately see the implementation of the results are successful.
The following is the contents of the delete.asp file.
% @language = "VBScript"%
《%
Response.buffer=true
Response.expires=0

%》
"The!--#include virtual="/news/data/data.inc "
《%

Set rs = Server.CreateObject ("ADODB.") Recordset ")
Sql= "SELECT * from Data order by News_class asc,news_id Desc"
' Rs. pagesize=100
Rs.Open sql,conn,3,2


%》
"HTML"

"Head"
"Meta http-equiv=" Content-type "content=" text/html; charset=gb2312 ""
Information stored in the "title" News Database "/title"
Meta name= "generator" content= "Microsoft FrontPage 3.0"
"Style type=" text/c



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.