⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.asp

📁 简单的留言版asp原码,供学习参考,里边有详细说明
💻 ASP
字号:
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<title><%=title%></title>
<SCRIPT LANGUAGE="JavaScript">
<!--//
function check()
{
   if (isNaN(go2to.page.value))
		alert("请正确填写转到页数!");
   else if (go2to.page.value=="") 
	     {
		alert("请输入转到页数!");
		 }
   else
		go2to.submit();
}
//-->
</SCRIPT>
</head>
<body style="word-break:break-all">
<table border=0 cellpadding=0 cellspacing=0 width=350 align="center" style="table-layout:fixed; word-break:break-all">
  <tr> 
    <form method="post" action="index.asp?action=new">
      <td width="350"> 
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td width="20%" height="30">
<div align="right">name:</div></td>
            <td width="80%"> 
              <input name="Username" size="20" style="font-size: 12" maxlength="30">
            </td>
          </tr>
          <tr> 
            <td width="20%" height="30">
<div align="right">email:</div></td>
            <td width="80%"> 
              <input name="email" size="20" style="font-size: 12" maxlength="50">
            </td>
          </tr>
          <tr> 
            <td width="20%" height="30">
<div align="right">homepage:</div></td>
            <td width="80%"> 
              <input type="text" name="Home" value="http://" size="20" style="font-size: 12">
            </td>
          </tr>
          <tr> 
            <td width="20%" height="30">
<div align="right">message:</div></td>
            <td width="80%"> 
<textarea cols="33" name="ly" rows="5" wrap="VIRTUAL" style="font-size: 12"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="20%" height="30">&nbsp;</td>
            <td width="80%"> 
              <input type="submit" value="完&nbsp;成" style="font-size: 12" name="submit">
              <input type="reset" name="Submit" style="font-size: 12" value="清&nbsp;除">
            </td>
          </tr>
        </table>
      </td>
    </form>
  </tr>
<%set rs=server.createobject("adodb.recordset")
sql="select * from book where id order by up desc,id desc"
rs.open sql,conn,1,1
if rs.bof or rs.eof then
response.write "没有留言"
on error resume next
end if 
if not isempty(request("page")) then
pagecount=cint(request("page"))
else
pagecount=1
end if
rs.pagesize=pagesize
if pagecount>rs.pagecount or pagecount<=0 then
pagecount=1
end if
rs.AbsolutePage=pagecount
for i=1 to rs.pagesize %>
<tr><td align=right>第<a href=index.asp?action=admin><%=i%></a>条
<%if session("bxgzsadmin")<>"" and session("bxgzspass")<>"" then
if rs("up")=0 then%>
&nbsp;&nbsp;<a href=index.asp?action=up&id=<%=rs("id")%>><font color=#008800>固顶</font></a>
<%else%>
&nbsp;&nbsp;<a href=index.asp?action=noup&id=<%=rs("id")%>><font color=#ff0000>已固顶</font></a>
<%end if%>
&nbsp;&nbsp;<a href=index.asp?action=del&id=<%=rs("id")%>>删除</a>&nbsp;&nbsp;<a href=index.asp?action=tc>退出</a><%end if%><% if guest="yes" or session("bxgzsadmin")<>"" then%>&nbsp;&nbsp;<a href=hf.asp?id=<%=rs("id")%>>回复</a><%end if%></td></tr><tr>
<td><%if rs("up")=1 then%><img src=images/up.gif><%end if%>
时间:<%=rs("time")%>&nbsp;&nbsp;姓名:<%=rs("Username")%>&nbsp;&nbsp;MAIL:<a href=mailto:<%=rs("mail")%>><%=rs("mail")%></a></td></tr>
<tr><TD>HOMEPAGE:<a href=<%=rs("home")%> target=_blank><%=rs("Home")%></a></TD></tr>
<tr><td width=90% style="word-break:break-all">留言内容:<BR><%=ubb(rs("Ly"))%><br>
<%
a=rs("id")
set rrs = server.createobject("adodb.recordset")
rsql = "select * from HF where BH ='"&clng(a)&"'"
rrs.open rsql,conn,1,1
if not rrs.eof or rrs.bof then
for hfi=1 to rrs.recordcount
%>
<hr noshade color="#C1C1C1" size="1" width=100% style="border-style: dotted; border-width: 1">
<%=rrs("name")%>回复:&nbsp;&nbsp;&nbsp;&nbsp;时间<%=rrs("time")%>
<%if session("bxgzsadmin")<>"" and session("bxgzspass")<>"" then%>
&nbsp;&nbsp;<a href=index.asp?action=delhf&id=<%=rrs("id")%>>删除</a><%end if%>
<br> 
<%=ubb(rrs("HF"))%><br>
<%
rrs.movenext
next
end if
rrs.close
set rrs = nothing
%><br>
<hr noshade size=1 width='100%'color='#666666'></td></tr>
<%
rs.movenext
if rs.eof then exit for
next
%>
<TR><TD><table border="0" cellpadding="0" cellspacing="0" width="" ><tr> 
<td width="" height="6" colspan="3" valign="bottom" bgcolor="#ffffff">
<% response.write"<form name=go2to method=Post action='index.asp'>"
if pagecount=1 then
response.write "首页 上一页&nbsp;"
else
response.write "<a href=index.asp?page=1>首页</a>&nbsp;"   
response.write "<a href=index.asp?page="+cstr(pagecount-1)+">上一页</a>&nbsp;"
end if
if rs.PageCount-pagecount<1 then
response.write "下一页 尾页"
else
response.write "<a href=index.asp?page="+cstr(pagecount+1)+">下一页</a>&nbsp;"
response.write "<a href=index.asp?page="+cstr(rs.PageCount)+">尾页</a>"                    
end if 
response.write "&nbsp;页次:"&pagecount&"/"&rs.pagecount&"页</font>" 
response.write " 转到第<input type='text' name='page' size=2 maxLength=3 style='font-size: 9pt; color:#00006A; position: relative; height: 18' value="&PageCount&">页&nbsp;&nbsp;"
response.write "<input type='button' value='确 定' onclick=check()>"
%>
</td></form>
</tr>
</table></TD></TR>
<%
Select Case Request("action")
  Case "new"
   Call work_new
  Case "admin"
   Call work_admin
  Case "del"
   Call work_del
  Case "delhf"
   Call work_delhf
  Case "up"
   Call work_up
  Case "noup"
   Call work_noup
  Case "tc"
   Call work_tc
End Select

sub work_new
if trim(request.form("Ly"))="" then
response.write "<script>alert('信息不完整');"
response.write "location.href='javascript:history.back()'</script>"
response.end
end if
Username=inohtml(request.form("username"))
Mail=inohtml(request.form("email"))
Home=inohtml(request.form("home"))
Ly=inohtml(request.form("Ly"))
shijian=formatdatetime(now(),1)
if instr(Ly,"<br>"&chr(10)&"<br>"&chr(10)&"<br>")<>0 then
response.write "<script>alert('请少量输入换行符');"
response.write "location.href='javascript:history.back()'</script>"
response.end
end if
countHF=split(HF,"<br>")
if ubound(countHF)>20 then
response.write "<script>alert('回车符超过最大限制20个');"
response.write "location.href='javascript:history.back()'</script>"
response.end
end if

if username="" then 
username="游客"
end if
if mail="" then 
mail="无"
end if
if len(username)>20 or len(mail)>20 or len(home)>100 then
response.write"<script>alert('信息过长');location.href='javascript:history.back()'</script>"
response.end
end if
if len(Ly)>cint(Num) then 
response.write "<script>alert('内容超过最大文字数量"&num&"个');"
response.write "location.href='javascript:history.back()'</script>"
response.end
end if
if Ly="" then
response.write"<script>alert('缺少留言内容');location.href='javascript:history.back()'</script>"
response.end
end if
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from book"
rs.open sql,conn,1,3
rs.addnew
Application.Lock
rs("Username")=username
rs("Mail")=mail
rs("Home")=home
rs("Ly")=ly
rs("time")=shijian
rs.update
Application.Unlock
rs.close
set rs=nothing
response.redirect "index.asp"
response.end
end sub

sub work_admin
%>
<tr><td>
<table border="0" width="224" height="45" cellspacing="1" bordercolorlight="#FFFFFF" bordercolordark="#C0C0C0" cellpadding="0">
    <tr>
      <td width="346" height="1" colspan="2" align="center"><b>管理登陆</b></td>
    </tr>
    <tr><form method="post" action="admin.asp">
      <td width="193" height="1" align="center">名称:</td>
      <td width="196" height="1" align="center">
      <input type="text" name="Username" size="22" style="width: 89; height: 19">
      </td>
    </tr>
    <tr>
      <td width="193" height="45" align="center">密码:</td>
      <td width="196" height="45" align="center">
        <input type="password" name="PassWord" size="22" style="width: 89; height: 19">
      </td>
    </tr>
    <tr>
      <td width="330" height="1" align="center" colspan="2">
<input type="submit" name="Submit" value="[确定]">
        <a href=adminxg.asp>更改用户</a></td></form>
    </tr></form>
  </table></td></tr>
<%
response.end
end sub

sub work_del
if session("bxgzsadmin")<>"" and session("bxgzspass")<>"" then
sql="delete from book where id="&clng(request("id"))
set rs=conn.execute(sql)
set rs=nothing
sql="delete from HF where BH='"&clng(request("id"))&"'"
set rs=conn.execute(sql)
set rs=nothing
response.redirect "index.asp"
response.end
else
response.redirect "index.asp"
response.end
end if
end sub

sub work_delhf
if session("bxgzsadmin")<>"" and session("bxgzspass")<>"" then
sql="delete from HF where id="&clng(request("id"))
set rs=conn.execute(sql)
set rs=nothing
response.redirect "index.asp"
response.end
else
response.redirect "index.asp"
response.end
end if
end sub

sub work_up
if session("bxgzsadmin")<>"" and session("bxgzspass")<>"" then
sql="update book set up=1 where id="&clng(request("id"))
set rs=conn.execute(sql)
set rs=nothing
response.redirect "index.asp"
response.end
else
response.redirect "index.asp"
response.end
end if
end sub

sub work_noup
if session("bxgzsadmin")<>"" and session("bxgzspass")<>"" then
sql="update book set up=0 where id="&clng(request("id"))
set rs=conn.execute(sql)
set rs=nothing
response.redirect "index.asp"
response.end
else
response.redirect "index.asp"
response.end
end if
end sub

sub work_tc
session("bxgzsadmin")=""
session("bxgzspass")=""
session.abandon
response.redirect "index.asp"
response.end
end sub
%>
</table>
</body>
</html>
<%
rs.close
set rs=nothing
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -