急,十万火急!如何用asp 做留言板的添加留言?和删除留言?要源代码
3个回答
展开全部
1、用ACCESS新建一个数据库,位置放在你站点的根目录下,名称为:test.mdb
2、新建一个表,表名con
3、在con表里面建两个字段:id,类型为【自动编号】;comment,类型为【备注】
4、保存并关闭。
5、运行下面的程序。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.MapPath("test.mdb")
dim Rs
set Rs = Server.CreateObject("ADODB.Recordset")
dim Sql
dim action
action = request.Form("action")
If action = "add" then
Sql = "insert into con (comment) values ('"&request.Form("commentDetial")&"')"
Conn.execute(Sql)
elseif action = "del" then
Sql = "delete from con where id="&request.Form("thisID")
Conn.execute(Sql)
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>留言版</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="index.asp">
<textarea name="commentDetial" id="commentDetial" cols="45" rows="5"></textarea>
<input name="action" type="hidden" value="add" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<form id="form2" name="form2" method="post" action="index.asp">
要删除留言的ID:<input type="text" name="thisID" id="thisID" />
<input name="action" type="hidden" value="del" />
<input type="submit" name="button2" id="button2" value="删除" />
</form>
<div>
<%
Sql="select * from con order by id asc"
Rs.open Sql,Conn,1,1
if not Rs.Eof then
do until Rs.Eof
response.Write("ID是:"&Rs("id")&"<br>留言是:"&Rs("comment")&"<hr>")
Rs.movenext
loop
end if
%>
</div>
</body>
</html>
2、新建一个表,表名con
3、在con表里面建两个字段:id,类型为【自动编号】;comment,类型为【备注】
4、保存并关闭。
5、运行下面的程序。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.MapPath("test.mdb")
dim Rs
set Rs = Server.CreateObject("ADODB.Recordset")
dim Sql
dim action
action = request.Form("action")
If action = "add" then
Sql = "insert into con (comment) values ('"&request.Form("commentDetial")&"')"
Conn.execute(Sql)
elseif action = "del" then
Sql = "delete from con where id="&request.Form("thisID")
Conn.execute(Sql)
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>留言版</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="index.asp">
<textarea name="commentDetial" id="commentDetial" cols="45" rows="5"></textarea>
<input name="action" type="hidden" value="add" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<form id="form2" name="form2" method="post" action="index.asp">
要删除留言的ID:<input type="text" name="thisID" id="thisID" />
<input name="action" type="hidden" value="del" />
<input type="submit" name="button2" id="button2" value="删除" />
</form>
<div>
<%
Sql="select * from con order by id asc"
Rs.open Sql,Conn,1,1
if not Rs.Eof then
do until Rs.Eof
response.Write("ID是:"&Rs("id")&"<br>留言是:"&Rs("comment")&"<hr>")
Rs.movenext
loop
end if
%>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询