|
|
savearticle.asp "同上这也是安全的保证! <% if request.cookies("adminok")="" then response.redirect "login.asp" end if %> <% "判断字符段是否为空!如果不加判断会对保存数据库造成影响! if request.form("txttitle")="" then response.write "错误提示:未输入标题!" "显示问题,强制暂停 response.end就是这个用处! "大家可从中慢慢体会! response.end end if "同上 if request.form("txtcontent")="" then 数据挖掘论坛 response.write "错误提示:未输入内容!" response.end end if %> "articleconn.asp是数据库连接位置,分开放是因为数据库是可下载的! "以后用户改数据库名可保正不被人看到 <!--#include file="articleconn.asp"--> "这是自动换行的标识判断程序! "大家可下载动感首页更新看到,慢慢研究! <!--#include file="inc/articlechar.inc"--> <% "dim定义变量,VB爱好者的当然相当熟悉了(注意:不可重复定义) dim listname dim url dim title dim content dim sql dim rs dim filename dim articleid dim outfile
"htmlencode2看了articlechar.inc进行过滤 "注意:txttitle,txtcontent,txturl的变化(几乎所有的ASP程序的关键) "阿喔认为,动感万不变,只有字符段变化,这是方便更新的关键! " title=htmlencode2(request.form("txttitle")) content=htmlencode2(request.form("txtcontent")) url=htmlencode2(request.form("txturl"))
"链接数据库articleconn.asp以帮你作了! "现在知道include的妙用了吧! "阿喔的http://asp.on.net.cn/都使用了include其方便更新帮了阿喔 数据挖掘工具 "一个大忙! set rs=server.createobject("adodb.recordset") sql="select * from learning where (articleid is null)"
"打开数据库 conn,1,3中3是关键,写的意思可别少了! rs.open sql,conn,1,3 "添加新的数据 rs.addnew "大家看三个字符右出现了RS("title")表示数据库中项的名称 "大家打开new.dmb就知道了!三个变量赋予数据库 rs("title")=title rs("content")=content rs("url")=url rs("dateandtime")=date() rs.update "ID为自动添加! articleid=rs("articleid")
关闭数据库是一个习惯,要不然会影响服务器速度,造成系统崩溃! rs.close set rs=noting conn.close set conn=nothing
"完成页面添加后制动进入index.asp页 response.redirect "index.asp" %>
大家注意的是两点: 1.判断句数据是否为空是必要的,要不然会造成数据无法添加 2.Txttitle,txtil和txtcontent文字段,如何提交的数据库是关键
|