dreamweaver,asp怎么制作留言板

dreamweaver,asp怎么制作留言板,第1张

需要动态网页开发技术,不知道你目前学的怎么样。先要架设安装IIS服务器,用来解析ASP程序,下载安装一个数据库,你可以使用SQL server数据库。

创建一个asp文件,里面创建留言标题,留言人信息,手机号,留言内容等,使用代码连接数据库,代码如下。

<%

Dim Database

Database="datamessage"

Dim Conn,ConnStr

 Set conn = Server.CreateObject("ADODB.Connection")

ConnStr="Provider=sqloledbServer=localhostdatabase="&Database&"uid=sapwd="

Conn.open ConnStr

%>

再次新建一个名为:default.asp的文件,这个文件是显示和添加留言的页面

编码也需要改为GB2312

在这里输入的代码如下:

<!--#include file="conn.asp"-->

<%

if request("action")="addmessagesave" then

if trim(request("memo"))="" then

Response.Write("<script lanuage=javascript>alert('留言内容不能为空!')location='message.asp'</script>")

response.End()

End if

set rsa=Server.CreateObject("ADODB.RecordSet")

strsqla="select  * from [message]"

    rsa.open strsqla,conn,3,2 

rsa.addnew

rsa("memo")=request("memo")

rsa("time1")=now

rsa.update

Response.Write("<script lanuage=javascript>alert('留言成功!')location='message.asp'</script>")

response.End()

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>

<style>

*{margin:0pxpadding:0pxfont-size:14pxcolor:#000000}

a{font-size:14pxcolor:#999999}

body{margin:0 autoline-height:30px}

</style>

</head>

<body>

<table width="培源兆930" height="553" border="0" align="center" cellpadding="0" cellspacing="0"   >

  <tr>

    <td width="230" valign="top" align="center">

<br/><br/><br/>

<a href="manage.asp">留言管理</a>配租

<br/><br/>

 </td>

  <td width="700" height="553" valign="top" align=left>

  留言 <div class=height9> </div>

   <br/><br/>

     <br/>

    <%

    message  

addmessage

    %>

    

</td>

  </tr>

</table>

</body>

</html>

<%

sub addmessage()

%>

<form id="form1" name="form1" method="post" action="?action=addmessagesave">

<table width="519" height="200" border="0">

  <tr>

    <td width="94" height="55">&nbsp</td>

    <td width="415">

      <input type="hidden" name="dd" value="0"  checked="checked"/>       <裂带/td>

  </tr>

  <tr>

    <td height="104" align=center>内容:</td>

    <td><label>

      <textarea name="memo" cols="50" rows="6" ></textarea>

    </label></td>

  </tr>

  <tr>

    <td height="33">&nbsp</td>

    <td>

     

        <input type="submit" name="Submit" value="提交" />      </td>

  </tr>

</table>

</form>

<%

end sub

SUB message()

set rs=Server.CreateObject("ADODB.RecordSet")

sql="select * from message  order by id desc"

rs.open sql,conn,1,1

if rs.eof then 

 

if request("key")<>"" then

response.write("<div style=""text-align:center"">没有查到您要查找的留言!</div>")

else

response.write("<div style=width:500pxheight:50pxtext-align:center>暂时没有留言留言!</div>")

End if

else

response.write("<div >")

PERPAGE=10

if request("pageno")="" or isNumeric(request("pageno"))=0 or request("pageno")<"1" then

curpage = 1

else

curpage = cint(request("pageno"))

end if

 

rs.pagesize = PERPAGE

if curpage>rs.pagecount then curpage=rs.pagecount

rs.absolutepage = curpage

for i=1 to rs.pagesize

if rs.eof then 

exit for

end if

%>

<table width="553" height="100" border="0" cellpadding="0" cellspacing="0" bgcolor=#ffffff style="border:1px solid #ccccccmargin-left:10pxmargin-top:5px">

 <tr>

   <td  style="padding-left:20px">[内容]</td>

   <td class="xb-a04"><%=rs("memo")%></td>

   <td>&nbsp</td>

  </tr>

 <tr>

   <td height="31" style="padding-left:20px"></td>

   <td class="xb-a04"><%

%></td>

   <td>[时间:<%=rs("time1")%>]</td>

  </tr>

<%if rs("hui")<>"" then%>

 <tr>

   <td style="padding-left:20px">[回复]</td>

   <td colspan="2" class="xb-a04" align="left">&nbsp&nbsp<%=rs("hui")%></td>

  </tr>

  <%End if%>

</table>

 <%

rs.movenext

next

if curpage = 1 then 

response.write "</div><BR><div style=width:440pxheight:30pxtext-align:center> 首页 | 上一页 | "

else

response.write "</div><BR><div style=width:440pxheight:30pxtext-align:center ><a href='?pageno=1'>首页</a> | <a href='?pageno="&curpage-1&"&leixing="&leixing&"'>上一页</a> | "

end if 

if curpage = rs.pagecount then

response.write "下一页 | 尾页</div>"

else

response.write "<a href='?pageno="&curpage+1&"&leixing="&leixing&"'>下一页</a> | <a href='?pageno="&rs.pagecount&"&leixing="&leixing&"'>尾页</a></div>"

end if

rs.close

end if

End sub

%>

新建一个管理留言的页面,名为manage.asp

同样先改编码为GB2312去掉原来的代码重新输入新的代码如下:

<!--#include file="conn.asp"-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html charset=gb2312">

<title>无标题文档</title>

<style type="text/css">

<!--

body {font-size: 12px color: #000000 font-family: 宋体}

td {font-size: 12px color: #000000 font-family: 宋体}

.t1 {font:12px 宋体color=000000} 

.t2 {font:12px 宋体color:ffffff} 

.bt1 {font:14px 宋体color=000000} 

.bt2 {font:14px 宋体color:ffffff} 

A:link {color: #000066}

A:visited {color: #000066}

A:hover {color: #ff0000}

A.r1:link {font-size:12pxtext-decoration:underlinecolor:#000000}

A.r1:visited {font-size:12pxtext-decoration:underlinecolor:#000000}

A.r1:hover {font-size:12pxtext-decoration:underlinecolor:#ff0000}

A.r2:link {font-size:12pxtext-decoration:underlinecolor:#ffffff}

A.r2:visited {font-size:12pxtext-decoration:underlinecolor:#ffffff}

A.r2:hover {font-size:12pxtext-decoration:underlinecolor:#ff6600}

A.r3:link {font-size:12pxtext-decoration:nonecolor:#000000}

A.r3:visited {font-size:12pxtext-decoration:nonecolor:#000000}

A.r3:hover {font-size:12pxtext-decoration:underlinecolor:#ff0000}

.bd{ background:#03F}

-->

</style>

</head>

<body>

<%

dim filename

dim biaoname

filename="message.asp"

biaoname="message"

%>

<center>

<table width="784" height="45" border="0" align="center">

  <tr>

    <td width="386" height="41" align=right>留言-管理</td>

    <td width="382">&nbsp</td>

  </tr>

  <tr>

    <td width="386" height="41" align=right>&nbsp</td>

    <td width="382">&nbsp</td>

  </tr>

</table>

<%

if request("action")=""  then '显示信息

%>

<TABLE width="393" border="0" cellpadding="4" cellspacing="1" bgcolor="#ffffff" align="center"> 

  

  <tr height=20 bgcolor="BEBFD9"> 

      <TD width="46" height="20" align="center" class=bd><font color="#FFFFFF"><b>编号</b></font></TD>

      <TD width="63" align="center" class=bd><font color="#FFFFFF"><b>留言时间</b></font></TD>

      <TD width="98" align="center" class=bd><font color="#FFFFFF"><b>内容</b></font></TD>

      <TD width="59" align="center" class=bd><font color="#FFFFFF"><b>回复</b></font></TD>

      <TD width="59" align="center" class=bd><font color="#FFFFFF"> 

       <input type='submit' value='删除'> 

    </font></TD> 

  </TR> 

<%

dim strsql

set rs=server.createobject("adodb.recordset") 

strsql="select  * from "&biaoname&" order by Id desc"

  rs.open strsql,Conn,3,2  

 

  if rs.eof then 

response.write("<div style=width:500pxheight:500pxtext-align:center>没有信息</div>")

else

'response.write("<div style=width:500pxheight:500px>")

PERPAGE=15

if request("pageno")="" or isNumeric(request("pageno"))=0 or request("pageno")<"1" then

curpage = 1

else

curpage = cint(request("pageno"))

end if

 

rs.pagesize = PERPAGE

if curpage>rs.pagecount then curpage=rs.pagecount

rs.absolutepage = curpage

%>

<%

for i=1 to rs.pagesize

if rs.eof then 

exit for

end if

%>

<tr height=20  <%if i mod 2 = 0 then

response.write("bgcolor=#cccccc")

else

response.write("bgcolor=#EEEeee")

End if

%>>

 <TD height="27" align="center" ><font color="#000000"><b><%=rs("id")%></b></font></TD>

 <TD align="center" ><font color="#000000"><b><%=rs("time1")%></b></font></TD>

 <TD align="center" ><font color="#000000"><b><%=rs("memo")%></b></font></TD>

 <TD align="center" ><a href=?action=hui&id=<%=rs("id")%>>点击回复</a></TD>

 <TD align="center" ><a href=?action=del&id=<%=rs("id")%>>删除</a></TD>

    </TR>

    <%if rs("hui")<>"" then%>

<tr height=20  bgcolor="#eeeeee" > 

<TD width="46" height="27" align="center" >回复:</TD>

<TD colspan="4" align="left" >&nbsp

                 

                 

                 <%=rs("hui")%>

                 

                 </TD>

   </TR> 

<%End if%>

<%

rs.movenext

next

%>

</TABLE>

<% if curpage = 1 then 

response.write "<br/><div style=width:500pxheight:30pxtext-align:center> 首页 | 上一页 | "

else

response.write "<br/><div style=width:500pxheight:30pxtext-align:center><a href='?pageno=1'>首页</a> | <a href='?pageno="&curpage-1&"&typeid="&request("typeid")&"'>上一页</a> | "

end if 

if curpage = rs.pagecount then

response.write "下一页 | 尾页</div>"

else

response.write "<a href='?pageno="&curpage+1&"&leixing="&leixing&"'>下一页</a> | <a href='?pageno="&rs.pagecount&"&typeid="&request("typeid")&"'>尾页</a></div>"

end if

rs.close

end if

end if

'--------------------------------------------------------------修改完成----------------

if request("action")="del" then '删除

id=request("id")

set rs=server.createobject("adodb.recordset")

sql="SELECT * from "&biaoname&" where id="&cstr(id)

rs.open sql,conn,1,3

rs.delete

'rs.update  

response.Write "<script>alert('删除成功!')this.location.href='"&filename&"'</SCRIPT>"

end if

if request("action")="hui" then '回复

%>

<form action="?action=huisave" method="post">

<table width="454" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="52" height="168">回复:</td>

    <td width="402"><label>

      <textarea name="hui" id="textarea" cols="45" rows="5"></textarea>

    </label>

      <input type="hidden" name="id" value="<%=request("id")%>">

    </td>

  </tr>

  <tr>

    <td height="59">&nbsp</td>

    <td><label>

      <input type="submit" name="button" id="button" value="提交">

    </label></td>

  </tr>

</table>

</form>

<%End if

if request("action")="huisave" then '删除

if request("hui")="" then

response.write ("<script>window.alert('回复内容不能为空!')this.location.href='message.asp'</script>")

response.end

End if

set rs1=server.CreateObject("ADODB.RecordSet")

sql="SELECT * from  "&biaoname&"  where id="&request("id")

rs1.open sql,conn,3,2

rs1("hui")=request("hui")

rs1.update

rs1.close

response.write ("<script>window.alert('回复成功!')this.location.href='message.asp'</script>")

End if

%>

</center>

</body>

</html>

运行调式程序

打开一个IE浏览器

输入:http://localhost/

地址

就可以进入到留言板界面,进行留言了

点击左边的留言管理,就可以进入留言管理界面,在留言管理界面可以回复和删除留言信息。

非握简零坊『差好留言本v3.4』功能以下:1、发布功能(用户可以直接发布留言)

2、昵称、内容为必填,其他为选填。

3、管理员(回复、删除信息;新增、修改、删除管理员)

4、设置(网页名称、网页返回地址、网页关键字、网页介绍、设置显示公告、是否回复才显示)

5、整个程序就两个文件一个数据库(可将两个文件合并成一个文件)。

6、代码都带虚皮铅有注释,便于用户修改。

7、管理员密码采用md5加密。

演示地址: http://www.ztren.com/Demo/Books/下载地址: http://down.chinaz.com/soft/21760.htm

你给的地址我们是访问不了的...那是你本机上的测试...呵呵... 制作过程大概就几个 1.做PS...就是枝搭要用的图片,切好页面... 2.建好数据库...建立页面与数据库的连接... 3.添加程序主要功能...如,发表留言,显示留言,或者还有用登陆等等功能!!! 4.建产后台...用于留言本的管理...如留言的删除,查看(也可以作IP的查看)等绝搭历等.. 写的不全就不要怪了并搜...希望对你有帮助哦...


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12483180.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存