📄 addnew.aspx
字号:
<%@import namespace='system.data'%>
<%@import namespace='system.data.oledb'%>
<script language=vb runat='server'>
sub t(errstring as string)
response.write (errstring & ",返回<a href='javascript:history.back()'>更正</a>"):response.end
end sub
sub submitstart(sender as object,e as eventargs) '提交处理
dim xingbieT as string,baomiT as boolean '提交数据检查
if trim(nicheng.value)="" then t("昵称必须填写")
if baomi1.value<>1 or baomi2.value<>2 then t("保密设置拒绝跨站定义")
if trim(biaoti1.text)="" or trim(neirong1.text)="" then t("标题及内容均必须填写")
if xingbie1.checked then xingbieT="男" else xingbieT="女"
if baomi1.checked then baomiT=false else baomiT=true
dim nichengT=replace(nicheng.value,"'","&$39;")
dim biaotiT=replace(biaoti1.text,"'","&$39;")
dim neirongT=replace(neirong1.text,"'","&$39;")
if instr(zhuye.value,"'")<>0 or instr(dizhi.value,chr(34))<>0 then t("主页地址不能含有 ' " & chr(34) & " 符号")
if instr(youxiang.value,"'")<>0 or instr(dizhi.value,chr(34))<>0 then t("邮箱地址不能含有 ' " & chr(34) & " 符号")
if instr(dizhi.value,"'")<>0 or instr(dizhi.value,chr(34))<>0 then t("你的地址不能含有 ' " & chr(34) & " 符号")
if instr(oicq.value,"'")<>0 or instr(dizhi.value,chr(34))<>0 then t("你的OICQ不能含有 ' " & chr(34) & " 符号")
if len(neirongt)<5 or len(neirongt)>30000 then t("留言内容过少或过多")
if len(biaotit)<5 then t("留言标题不能少于5个字符")
if request.cookies("LanLiBook") is nothing then '过滤浇水高手:)
response.cookies("lanlibook")("guanshui")=date.now
else
if isdate(request.cookies("lanlibook")("guanshui"))=false then t("拒绝COOKIES测试")
if datediff("s",request.cookies("lanlibook")("guanshui"),date.now)<10 then response.cookies("lanlibook")("guanshui")=date.now:t("你的留言已经发表请不要重复提交,想浇水请到菜园子里去:)")
response.cookies("lanlibook")("guanshui")=date.now
end if
dim conn1=ConfigurationSettings.AppSettings("databaseconn") & server.mappath(ConfigurationSettings.AppSettings("databasepath")) '得到web.config中数据库的完整路径
'以下开始数据库添加
dim link1=new oledbconnection(conn1)
link1.open
dim com1=new oledbcommand("insert into table1(title,body,homepage,email,oicq,address,sex,noopen,dates,gengxindates,ip,liuyanzuozhe) values ('" & biaotit & "','" & neirongt & "','" & zhuye.value & "','" & youxiang.value & "','" & oicq.value & "','" & dizhi.value & "','" & xingbiet & "'," & baomit & ",'" & date.now & "','" & date.now & "','" & request.userhostaddress & "','" & nichengt & "')",link1)
err.clear
on error resume next
com1.executereader()
if err.number<>0 then t("你输入的数据其中有几项过长,请减少使用 ' 符号或减少提交的数据量")
com1=nothing:link1.close():link1=nothing
response.Redirect ("index.aspx"):Response.end
end sub
</script>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; Charset=gb2312"/>
<META name="GENERATOR" content="网络程序员伴侣(Lshdic)2004_星钻超爽版"/>
<TITLE>签写新留言</TITLE>
<style>
*{font-size:12px;font-family:宋体}
a{color:maroon;text-Decoration:none;}
a:hover{color:blue;text-Decoration:underline;}
.class1{border:1 solid black}
</style>
</HEAD>
<BODY>
<TABLE rules="all" bordercolor='menu' width="500" height="300" cellspacing="0" cellpadding="5" style='border-Collapse:collapse;' align=center>
<tr>
<td bgcolor="#619CE7" style='color:white;' height=20>
<center><b>签写新留言(注意:带 * 号的为必须填写项,否则选添)</b></center>
</td>
</tr>
<tr><Td style='padding:0;padding:5;'>
<form method="post" runat='server'>
你的昵称:<input runat='server' id='nicheng' class="class1" maxlength="15"> * 你的主页:<input runat='server' id='zhuye' class="class1" maxlength="100"><p>
你的邮箱:<input runat='server' id='youxiang' class="class1" maxlength="100"> 你的OICQ:<input runat='server' id='oicq' class="class1" maxlength="16"><p>
你的地址:<input runat='server' id='dizhi' class="class1" maxlength="50"> 尽量简短,格式如“省市”“市”<p>
你的性别:<asp:radiobutton runat='server' id='xingbie1' groupname="group1" checked text="男"/><asp:radiobutton runat='server' id='xingbie2' groupname="group1" text="女"/> *<p>
留言保密:<input runat='server' name='baomi' type='radio' checked value='1' id='baomi1'><label for='baomi1'>所有访客自由查看</label><input runat='server' name='baomi' type='radio' value='2' id='baomi2'><label for='baomi2'>仅管理员(站长)可看</label> *<p>
留言标题:<asp:textbox runat='server' id='biaoti1' width=385 class="class1" maxlength="50"/> *<p>
留言内容 * 限制在5-30000字以内<br>
<asp:textbox runat='server' id='neirong1' textmode=1 columns="70" rows="7" class="class1"/><br>
<center><input type='button' runat='server' id='tijiao' value='OK了,提交留言' onserverclick="submitstart"></center>
</td></tr></table>
</form>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -