日期:2011-10-24 浏览次数:21589 次
好久没有写过asp了,这回写个留言板还真觉得有点难度,竞然写了整整一天,哈哈.
就只有留言其它的都什么也没写,采用三层结构(不知道算不算,本来对三层的概念很糊涂)
演示的留言板,希望各位大哥大姐如果发现有漏洞的话请在这里告诉我,千万不要黑我的网站,在这里小弟先谢过了.
index.asp
<%@codepage=65001%>
<%
optionexplicit
%>
<%Response.Charset="utf-8"%>
<%Session.CodePage=65001%>
<!--#includefile="AccHelper.asp"-->
<!--#includefile="Common.asp"-->
<!--#includefile="DAL_Guest.asp"-->
<!--#includefile="MOD_Guest.asp"-->
<!--#includefile="BLL_Guest.asp"-->
<%
Dimmybll
DimmyList
Setmybll=newBLL_Guest
SelectCaseRequest("tCMD")
Case"SAVE"
mybll.Insert()
Case"DEL"
mybll.Delete()
EndSelect
myList=mybll.FindByPage()
%>
<h2>客户留言</h2>
<p>
<formname="subForm"id="subForm">
<textareaid="con"name="con"cols="56"rows="6"wrap="VIRTUAL"></textarea>
<inputtype="button"name="submit"value="提交留言"onclick="$('guest/index.asp?tCMD=SAVE&content='+escape(this.form.con.value))"/>
</form>
</p>
<%=myList%>
BLL_Guest.asp
<%
'///<summary>
'///摘要说明。
'///</summary>
ClassBLL_Guest
Privatemycom,mymod,mydal
PrivateLI,UL
PrivateDEL
'获取信息
PublicSubGetGuest()
mydal.GetGuest(Id)
EndSub
'新增信息
PublicSubInsert()
mymod.Content=Request("content")
mymod.re=Request("Re")
mymod.Addtime=Now()
mymod.Ip=request.servervariables("HTTP_X_FORWARDED_FOR")
Iflen(mymod.Ip)<=0Thenmymod.Ip=request.servervariables("REMOTE_ADDR")
Callmydal.Insert(mymod)
EndSub
'更新信息
PublicSubUpdate()
Callmydal.Update(mymod)
EndSub
'删除信息
PublicSubDelete()
mydal.Delete(Request("Id"))
EndSub
'查找信息
PublicFunctionFindByPage()
DimPageSize,CurrentPage,WhereValue,OrderValue,RecordCount
DimobjRS
Dimtmp1,tmp2,tmp3,parms,i
DimtCMD
tCMD=Request("tCMD")
PageSize="8"
CurrentPage=Request("PageNo")
IfLen(CurrentPage)<=0Then
CurrentPage=1
EndIf
WhereValue=""
OrderValue="Id"
SetobjRS=mydal.FindByPage(PageSize,CurrentPage-1,WhereValue,OrderValue)
i=1
RecordCount=mydal.Count(WhereValue)
DoWhileNotobjRS.EOF
IftCMD="DEL"Then
DEL="<ahref=""?tCMD=DEL&Id="&objRS("Id")&""">删除</a>"
Else
DEL=""
EndIf
parms=Array(i,objRS("content"),objRS("ip"),objRS("addtime"),DEL)
tmp1=tmp1&mycom.Format(LI,parms)
objRs.Movenext
i=i+1
Loop
tmp3=mycom.Page(PageSize,CurrentPage,RecordCount,"guest/index.asp?tCMD=LIST")
parms=Array(tmp1,tmp3)
tmp2=tmp2&mycom.Format(UL,parms)
FindByPage=tmp2
EndFunction
&