++++++++ 求一ASP留言本基本代码 ++++++++++++++++++++++

minghui000 2003-10-18 01:50:33
我本想手写一个ASP留言本,但是花了2个星期看别人的代码还是看不懂。实在太难
网上的留言本代码也很难懂。不适合初学者

请问谁愿意高抬贵手,写一个ASP留言本基本需要的东西让我参考参考
只要最基本就OK了。例如管理员增加删除,留言本分页显示那些。谢谢~~~

分一定相送

方便的话可以发到我邮箱minghui_021@163.com
...全文
171 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
TT008 2003-12-05
  • 打赏
  • 举报
回复
study
minghui000 2003-10-19
  • 打赏
  • 举报
回复
没人跟帖啦?
minghui000 2003-10-19
  • 打赏
  • 举报
回复
我up~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
icebery 2003-10-19
  • 打赏
  • 举报
回复
'<<<<<<<<<<<<>>>>>>>>>>>>
Sub InsertInfo

Comment = Replace(Comment,VbCrlf,"<br>")
Comment = Replace(Comment,Chr(34),""")

set conn = server.createobject("adodb.connection")
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath(DataBaseName)
conn.Open DSNtemp

sqlstmt = "Insert into gb (Name,Email,Place,Url,Comment)"
sqlstmt = sqlstmt & " Values("
sqlstmt = sqlstmt & "'" & Name & "',"
sqlstmt = sqlstmt & "'" & Email & "',"
sqlstmt = sqlstmt & "'" & Place & "',"
sqlstmt = sqlstmt & "'" & Url & "',"
sqlstmt = sqlstmt & "'" & Comment & "'"
sqlstmt = sqlstmt & ")"

conn.execute(sqlstmt)

conn.close
set conn = nothing

End Sub

'<<<<<<<<<<<<>>>>>>>>>>>>
Sub ViewPage

set conn = server.createobject("adodb.connection")
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath(DataBaseName)
conn.Open DSNtemp
sqlstmt = "SELECT * from Gb ORDER BY date DESC"
'set rs = conn.execute(sqlstmt)
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlstmt, conn, 3, 3
If rs.EOF then
Response.write "No records in guestbook"
Else
TotalRecords = rs.recordcount
rs.Pagesize=10
TotalPages = cInt(rs.pagecount)
rs.absolutepage=Page

%> <font size=2 color="<%= TextColor %>" face="<%= Font %>"> 第<%= TotalRecords %>
条留言在第 <%= TotalPages %>页<br>
<br>
</font>
<%

For CountRecords = 1 to 10
If rs.EOF then Exit for

Daten = rs("Date")
Name = rs("Name")
Email = rs("Email")
Place = rs("Place")
Url = rs("Url")
If Url<>"" and InStr(Url,"http://")=0 then Url="http://"&Url
Comment = rs("Comment")
%>
<table width="600" cellpadding=0 cellspacing=2 border=0>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><b>日期:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2 color="<%= celltext %>"><%= Daten %></font></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><b>名字:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2><a href="mailto:<%= Email %>"><%= Name %></font></a></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><B>来自:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2 color="<%= celltext %>"><%= Place %></font></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><b>主页:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2><a href="<%= Url %>" target="_blank"><%= Url %></font></a></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><B>内容:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2 color="<%= celltext %>"><%= Comment %></font></td></tr>
</table><br>
<%
rs.movenext
Next
If Page > 1 Then
%>
<a href="<%= NameOfFile %>?Page=1"><font face="<%= Font %>" size=3><b><<</b></font></a>   
<a href="<%= NameOfFile %>?Page=<%= Page - 1 %>"><font face="<%= Font %>" size=3><b><</b></font></a>   
<%
End If
If NOT rs.EOF then
%>
<a href="<%= NameOfFile %>?Page=<%= Page + 1 %>"><font face="<%= Font %>" size=3><b>></b></font></a>   
<a href="<%= NameOfFile %>?Page=<%= TotalPages %>"><font face="<%= Font %>" size=3><b>>></b></font></a>
<%
End If
End If
conn.close
set conn = nothing
End Sub

If Mode = "Sign" then
If Flag = "" then
'If form has not been submitted, no flag is regongnised
WhatToDo = "Sign Guestbook"
Header
SignPage
Footer
End If
If Flag = 1 then
'If form has been submitted, flag will be set to 1
WhatToDo = "Sign Guestbook"
Header
If Not Validate then
'The "Validate" function writes Error message
Signpage
Else
InsertInfo
Response.write "<font color='" & textcolor & "' face='" & font & "' size=5>"
Response.write "成功!<br><br>"
Response.write "<a href='" & NameOfFile & "'>返回</a><br>"
Response.write "</font>"
Footer
End If
Footer
End If
Else
WhatToDo = "View Guestbook"
Header
Viewpage
Footer
End If

%>
icebery 2003-10-19
  • 打赏
  • 举报
回复
<SCRIPT LANGUAGE="VBScript" RUNAT="SERVER"></SCRIPT>
<%
' *******************************************************************
' * 配色 --------------------------------------------------------- *
' ************************ *
BodyBgcolor = "#ffffff" '* 底色 *
LinkColor = "#000099" '* 连接 *
ALinkColor = "#99ccff" '* 活动连接 *
VLinkColor = "#000099" '* 死连接 *
TextColor = "#000000" '* 文字颜色 *
HoverColor = "#99ccff" '* 鼠标覆盖色 *
TopcellBg = "#99ccff" '* 表头色 *
TopcellText = "#ffffff" '* 表头文字色 *
CellBg = "#ffffff" '* 表背景色 *
CellText = "#000000" '* 表文字色 *
' ************************ *
' * *
' * 字体和数据库设置 *
' * *
' * --------------------------------------------------------------- *
' **************************************** *
Font = "Arial" '* 字体 *
DataBaseName = "gb.mdb" '* 数据库设置 *
' **************************************** *
' * 旅者送大家的小礼物呀,你可以随便改,不过最好在你的首页上给我
' * 做个连接,不过份吧?呵呵 *
' * *
' * *
' * *
' *******************************************************************
session("fn") = "gb.asp"
' -----------------------------------------
' 程序数据部分
' -----------------------------------------

Mode = Request.QueryString("Mode")
Page = Request.QueryString("Page")
ShowTheCode = "yes"
If IsEmpty(Request.QueryString("Page")) then Page = 1


Flag = Request.Form("Flag")

If mode = "Sign" then
Name = Request.Form("Name")
Email = Request.Form("Email")
Place = Request.Form("Place")
Url = Request.Form("Url")
Comment = Request.Form("Comment")
End If


NameOfFile = Request.ServerVariables("Script_Name")

Sub Header
%>
<html>
<head>
<title>旅者留言BETA V1.0</title>
<style>
<!--
A:Hover {color:<%= HoverColor %>}
-->
</style>
</head>
<body bgcolor="<%= BodyBgColor %>" link="<%= LinkColor %>" alink="<%= ALinkColor %>" vlink="<%= VLinkColor %>" Text="<%= TextColor %>">
<p><a href="<%= NameOfFile %>?Mode=Sign"><font size=4 face="arial" color="#000000"><b><font size="2">留言</font></b></font></a><font size="2"><b>
<a href="<%= NameOfFile %>"><font face="arial" color="#000000">查看</font></a>
</b></font><br>
<br>
<%
End Sub

'<<<<<<<<<<<<>>>>>>>>>>>>
Sub Footer
%> <br>
<br>
<font face="<%= Font %>" size="2" color="<%= TextColor %>">旅者 - <a href="http://www.sakki.net">http://www.dream-fly.com</a>
</font> </body> </html> <%
Response.End
End Sub

'<<<<<<<<<<<<>>>>>>>>>>>>
Sub SignPage
%> </p>
<form action="<%= NameOfFile %>?Mode=Sign" Method="POST">
<table cellspacing=2 border=0>
<tr>
<td bgcolor="<%= TopCellBg %>"><font size=2 face="<%= Font %> color="<%= TopCellText %>"><b>大名:</b></font></td>
<td bgcolor="<%= CellBg %>"><input type="text" name="Name" value="<%= Name %>" MaxLength=30 size=30></td></tr>
<tr>
<td bgcolor="<%= TopCellBg %>"><font size=2 face="<%= Font %> color="<%= TopCellText %>"><b>邮件:</b></font></td>
<td bgcolor="<%= CellBg %>"><input type="text" name="Email" value="<%= Email %>" MaxLength=50 size=30></td></tr>
<tr>
<td bgcolor="<%= TopCellBg %>"><font size=2 face="<%= Font %> color="<%= TopCellText %>"><b>主页:</b></font></td>
<td bgcolor="<%= CellBg %>"><input type="text" name="URL" value="<%= URL %>" MaxLength=50 size=30></td></tr>
<tr>
<td bgcolor="<%= TopCellBg %>"><font size=2 face="<%= Font %> color="<%= TopCellText %>"><b>贵宝处:</b></font></td>
<td bgcolor="<%= CellBg %>"><input type="text" name="Place" value="<%= Place %>" MaxLength=50 size=30></td></tr>
<tr>
<td bgcolor="<%= TopCellBg %>"><font size=2 face="<%= Font %> color="<%= TopCellText %>"><b>金言留下:</b></font></td>
<td bgcolor="<%= CellBg %>"><textarea name="Comment" Cols=30 Rows=4><%= Comment %></textarea></td></tr>
<tr><td bgcolor="<%= TopCellBg %>"></td><td bgcolor="<%= CellBg %>">
<input type="Submit" value="好了">
<input type="Reset" value="想想">
</td></tr>
<input type="hidden" name="flag" value=1>
</table>
</form>
<%
End Sub

'<<<<<<<<<<<<>>>>>>>>>>>>
Function Validate
Dim ErrorMsg
ErrorMsg = "<ul>"
If Name = "" Then
ErrorMsg = ErrorMsg & "<li>大哥,你没名字呀!</li>"
End if
If Email = "" Then
ErrorMsg = ErrorMsg & "<li>我倒,没有email还来网上混l</li>"
ElseIf InStr(Email, "@") = 0 Then
ErrorMsg = ErrorMsg & "<li>骗我没上网呀,EMAIL起码有个@吧?</li>"
End if
If Comment = "" Then
ErrorMsg = ErrorMsg & "<li>没有留言呀!!!</li>"
ElseIf InStr(Comment, ">") <> 0 or InStr(Comment, "<") <> 0 Then
ErrorMsg = ErrorMsg & "<li>Do not use < or ></li>"
End if

ErrorMsg = ErrorMsg & "</ul>"
If Not ErrorMsg = "<ul></ul>" then
Response.write "<font size=2 color='" & ErrorColor & "' face='" & font & "' size=5>"
Response.write "出错拉!!!!<br></font>"
Response.write "<font size=2 color='" & TextColor & "' face='" & font & "' size=3>"
Response.write ErrorMsg
Response.write "</font><br><br>"
Validate = False
Else
Validate = True
End if
End Function



minghui000 2003-10-19
  • 打赏
  • 举报
回复
继续来跟帖啊~~~~
goldme76 2003-10-19
  • 打赏
  • 举报
回复
我做的那个信息发布系统里,你要的分页和删除什么的都有, 你总不能要我们帮你写个留言本吧,信息发布和留言本还不一回事
minghui000 2003-10-19
  • 打赏
  • 举报
回复
我再UP~~~~~~~~~快来帮忙啊啊~~~~~~~~~~
bineon 2003-10-18
  • 打赏
  • 举报
回复
http://www.91asp.cn/down/sort.asp?classid=14&Nclassid=203
Struggling 2003-10-18
  • 打赏
  • 举报
回复
到www.china-code.net里搜索吧!很多!!
qdubit 2003-10-18
  • 打赏
  • 举报
回复
关注!
minghui000 2003-10-18
  • 打赏
  • 举报
回复
我倒。连接数据库我会啊。我要的留言本。。。~嘿嘿。。。。翻页那些和管理员那部分比较难搞
bigcar 2003-10-18
  • 打赏
  • 举报
回复
uping
1蓝天1 2003-10-18
  • 打赏
  • 举报
回复
<%
'数据库连接
dim conn
dim connstr
dim db
'更改数据库名字
db="database/data.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath(""&db&"")
conn.Open connstr
sub endConnection()
conn.close
set conn=nothing
end sub
'结束
%>
给你个连接ACCESS的例子
1蓝天1 2003-10-18
  • 打赏
  • 举报
回复
up
minghui000 2003-10-18
  • 打赏
  • 举报
回复
能不能来一个用VBSCRIPT写。用ADO连接ACCESS的例子来看看。好象都不合乎要求哦

谢谢大家
htao007 2003-10-18
  • 打赏
  • 举报
回复
这是前面填写留言后处理数据的叶面程序:

<%
on error resume next
dim i
dim str1,str2,strN,strT,strS,strC
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
if not MyFileObject.fileexists(server.mappath("/test.txt")) then
set ContenText=MyFileObject.createtextfile(server.mappath("/test.txt"))
ContenText.close
end if
'````````````````````````````````````````
' 以上程序建立了一个 test.txt 文本文件
'````````````````````````````````````````
set tmptest=MyFileObject.opentextfile(server.mappath("/test.txt"))
Set Myfile=MyFileObject.GetFile(server.mappath("/test.txt"))
if Myfile.size >=262144 then
set tmpfile=MyFileObject.createtextfile(server.mappath("/tmp2.txt"))
for i=1 to 40
str1=tmptest.readline
str2=tmptest.readline
tmpfile.writeline(str1)
tmpfile.writeline(str2)
str1=" "
str2=" "
next
tmptest.close
tmpfile.close
Myfile.close
MyFileObject.copyfile server.mappath("/tmp2.txt"),server.mappath("/test.txt")
MyFileObject.deletefile server.mappath("/tmp2.txt")
end if
'````````````````````````````````````````
'以上程序控制test.txt文本内容的总量
'````````````````````````````````````````
strN=request("name")
strS=request("sex")
strT=now
strC=request("msg")
if strS=empty then strS="帅哥"
set fileTmp=server.createobject("scripting.filesystemobject")
set textTmp=fileTmp.createtextfile(server.mappath("/tmp1.txt"))
Set MyTextFile=fileTmp.opentextfile(Server.MapPath("/test.txt"),1)
textTmp.writeline(strN&" ("&strS &") 留言时间:"& strT)
textTmp.writeline(strC)
textTmp.close
set textTmp1=fileTmp.opentextfile(server.mappath("/tmp1.txt"),8,true)
while not MyTextFile.atendofstream
textTmp1.writeline(MyTextFile.readline)
wend
MyTextFile.close
textTmp1.close
fileTmp.copyfile server.mappath("/tmp1.txt"),server.mappath("/test.txt")
fileTmp.deletefile server.mappath("/tmp1.txt")

%>
<center>你的留言内容已经提交,即将转到留言浏览页面...</center>
qunluo 2003-10-18
  • 打赏
  • 举报
回复
楼上 oyiboy(coder)
你的一个页面的代码弄来俺看看!我喜欢!(比较喜欢JS)呵!!!拜托!!!!
qun-luo@163.com
离子漂浮物 2003-10-18
  • 打赏
  • 举报
回复
http://coder.126.com
我的网站,上面有一个只用一页代码写出来的简单留言板。你可以去看看啊。
dafei0320 2003-10-18
  • 打赏
  • 举报
回复
www.codecn.com
www.aspsky.com
很多啊!!!!
还需要的话!
我可以发给你啊!!!
加载更多回复(6)

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧