|
作者: wlbyyh [wlbyyh] 论坛用户 | 登录 |
本程序由下列页面组成 const.asp //打开数据库连接的。 <% Const BaseName = "book" StrUserName = "admin" Rem 数据库用户名 StrPassword = "databas" Rem 数据库密码 StrDBPath = "images\" & BaseName & ".mdb" Rem 数据库路径 DBDRIVER = "DBQ="+Server.Mappath(StrDBPath)+";uid="&StrUserName&";pwd="&StrPassword&";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" 'Access数据库用的驱动程序 Set conn = Server.CreateObject("adodb.connection")'定义打开数据库连接的connection对象 conn.open DBDRIVER'打开Images目录下的Databas数据库 %> 管理留言的登陆页面 为login.htm,下面这是判断登陆的Login.asp <!-- include file ="const.asp" --> <% Dim UserName,UserPwd,Logsql UserName=Replace(Trim(Request.form("User_idn")),"=","<br>") UserPwd=Replace(Trim(Request.form("User_pwn ")),"'","<br>") Set rs = Conn.Execute("SELECT * FROM fox_user where User_id="&UserName"") if rs("User_pw")<>User_pwd then %> <script language = "javascript"> alert("用户名或密码不符,请返回重新输入") </script> <% Response.redirect "login.htm" else Response.redirect "deltext.htm" End if rs.close rs = nothing conn.close conn = nothing %> 添加留言的Addtext.asp <!--#include file = "const.asp"--> <% Dim name,Oicq,email,title,text '定义变量 name = Replace(trim(Request.form("name")),"<","1")'接收从上addtext.htm表单传入的各项数据。并进行校验和去掉多余的空格 Oicq = Replace(trim(Request.form("Oicq")),"<","") email = Replace(trim(Request.form("email")),"<","") title = Replace(trim(Request.form("title")),"<","") text = Replace(trim(Request.form("text")),"VbCrLf","<br>") '以下语句判断接收的数值是否符合要求,如不符合则弹出提示。要求重写 if name="" or len(name)>50 then %> <script language="javascript">alert("请输入名字(长度不可以大于50)");history.back();</script> <% else if Oicq="" or Isnumeric(Oicq)<>true then %> <script language="javascript">alert("请输入QQ号码(必须是数字)");history.back();</script> <% else if email="" or len(email)>50 then %> <script language="javascript">alert("请输入邮箱地址(长度不可以大于50)");history.back();</script> <% else if text="" or len(text)>225 then %> <script language="javascript">alert("请输入内容(长度不可以大于225个字符)");history.back();</script> <% end if end if end if End if Set rs = Server.CreateObject("adodb.recordset")'定义recordset对象。对数据库操作 '以下语句是将接收的值输入数据库 sql = "SELECT * FROM booktext" rs.open sql,conn,1,3 rs.addnew rs("book_name") = name rs("book_qq") = Oicq rs("book_email") = email rs("book_title") = title rs("book_text") = text rs.Update %> <html> <head> <title>感谢您的留言</title> <style type="text/css"> <!--CSS样式表。定义页面上的文字大小和浏览器的滚动条的颜色--> <!-- A:link {COLOR: #000000; CURSOR: hand; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:visited {COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:active {COLOR: red; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:hover {COLOR: red; TEXT-DECORATION:none;font-size:9pt}body {font-size:9pt}td {font-size:9pt} BODY { SCROLLBAR-FACE-COLOR: #9999FF; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #FFFFFF; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #ffffff; } --> </style> </head> <body> <p> <p> 谢谢您的留言,请返回 <p align="center"><a href ="speakbook.htm">返回留言本</a> </body> </html> <% rs.close Set rs = nothing conn.close Set conn = nothing '从<%符合开始是关闭数据库连接 %> 用来删除留言的。Deltext.asp <!--#include file = "const.asp"--> <% Dim delsql '定义变量 Set delRs = Server.CreateObject("adodb.Recordset")'定义recordset对象 delsql = "Delete * from booktext where id="&trim(Request.form("id"))'打开数据库连接如果deltest.htm返回的ID和数据库中的ID相同则执行该语句 delrs.open delsql,conn,1,3'执行Sql语句删除指定ID的记录 Response.write "已成功删除" %> <html> <head> <title> 留言本管理区 </title> <style type="text/css"> <!-- A:link {COLOR: #000000; CURSOR: hand; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:visited {COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:active {COLOR: red; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:hover {COLOR: red; TEXT-DECORATION:none;font-size:9pt}body {font-size:9pt}td {font-size:9pt} BODY { SCROLLBAR-FACE-COLOR: #9999FF; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #FFFFFF; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #ffffff; } --> </style> </head> <body> <p> <p> <p align="center"><a href ="deltext.htm">返回管理页</a> <p align="center"><a href ="speakbook.htm">返回留言本</a> </body> </html> <% Response.End delrs.close Set delrs = nothing conn.close Set conn = nothing %> 显示留言的 Book.asp <!--#include file = "const.asp"--> <% Dim sql,book_name,book_text,book_date,book_email,book_qq,book_title,id Set rs = Server.CreateObject("adodb.recordset") set Rs = Conn.Execute("SELECT * FROM booktext ORDER BY ID DESC") %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>book</title> <style type="text/css"> <!-- A:link {COLOR: #000000; CURSOR: hand; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:visited {COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:active {COLOR: red; FONT-STYLE: normal; TEXT-DECORATION: none;font-size:9pt} A:hover {COLOR: red; TEXT-DECORATION:none;font-size:9pt}body {font-size:9pt}td {font-size:9pt} BODY { margin-left: 0px; margin-top: 0px; SCROLLBAR-FACE-COLOR: #9999FF; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #FFFFFF; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #ffffff; background-color: #000000; } --> </style></head> <body><%'以下语句是使用循环语句输出数据库中的所有数据 rs.MoveFirst Do while not rs.Eof id = rs("id") book_name = rs("book_name") book_text = rs("book_text") book_date = rs("book_date") book_email = rs("book_email") book_qq = rs("book_qq") book_title = rs("book_title") %> <table width="551" height="120" border="0" cellpadding="1" cellspacing="1"> <tr> <td height="20" bgcolor="#000000"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" align="left" bgcolor="#99CCFF"><%=id%> 留言人:<%=book_name%> 主题: <%=book_title%> 发表日期:<%=book_date%> <a href = "mailto:<%=book_email%>"> <img src="images/folder.gif" width="16" height="16" border="0" onmouseover=alt="发邮件给<%=book_name%>"></a> <a href = "#"> QQ:<%=book_qq%></a> </td> </tr> </table></td> </tr> <tr> <td bgcolor="#000000"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="99" valign="top" bgcolor="#66CCFF">留言内容:<p><%=book_text%></td> </tr> </table></td> </tr> </table> <% rs.MoveNext loop %> </body> </html> <% rs.close Set rs = nothing conn.close Set conn = nothing %> 最简单的啦。 |
地主 发表时间: 04-03-13 12:35 |
回复: wlbyyh [wlbyyh] 论坛用户 | 登录 |
没有顶吗?我自己顶一下吧。 |
B1层 发表时间: 04-03-15 19:38 |
回复: wangan [wangan] 论坛用户 | 登录 |
好东西 谢谢你发出来顶 |
B2层 发表时间: 04-03-15 19:58 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号