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

📄 guestbook.asp

📁 都乐电子书店!!! !!! !!! !1
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%
'--------------------------------------------
'	数据库结构:
'
'		库名:dule
'		表名:gbook
'
'	字段:
'		id
'		name
'		address
'		ip
'		email
'		homepage
'		time
'		content
'		show
'		replyid
'
'		表名:gbookreply
'
'	字段:
'		序号
'		回复
'		内容		
'--------------------------------------------
%> 
<style type="text/css">
<!--
td {  font-size: 14px}
-->
</style>


    <td></td>
    <td width=500 height=100%>
      
  <p class=left>&nbsp; 
  <table align="center" border=0 cellspacing=0 cellpadding=0 height="95%">
        <tr><td height=200>
 
<Script Language=VBscript Runat=Server>
Function sqlstr( sql )
	sqlstr = Replace(sql,"'","''")
    'sqlstr = Replace(sql,"""","""""")
End Function
</script>
        <%
set ConDule = Server.CreateObject( "ADODB.Connection" )
set RecDule = Server.CreateObject( "ADODB.Recordset" )
Set RecReply = Server.CreateObject( "ADODB.Recordset" )

'	打开数据库
ConDule.Open "dule","sa","gbs108@www"


job = Request("job")
If job="" Then job = "display"

If job<>"charge" Then Session("logined") = False    '安全措施,此句不能少

'================================================================================================
Select Case job		'选择 job
'================================================================================================
Case "fill" 		'填写留言
%> 
        <form action="guestbook.asp?job=add" method="post" name="fillin" id="fillin">
            
          <table height=100% align="center" border=0 cellspacing=0 cellpadding=0>
            <tr> 
              <td height="25"> 
                <div align="center">
                  <p>〖<a href="guestbook.asp?job=display&page=1">查看以前的顾客留言</a>〗</p>
                  <p>〖<a href="http://dule.gbsource.net">返回都乐</a>〗</p>
                  <p>&nbsp;</p>
                </div>
              </td>
            </tr>
            <tr> 
              <td height="25"> 
                <input type="hidden" name="job2" value="add">
                你的姓名: 
                <input type=text size=18 maxlength=75 id=username name=username>
                &nbsp;&nbsp;&nbsp;你来自: 
                <input type="text" name="address" id="address" size=18 maxlength="75">
              </td>
            </tr>
            <tr> 
              <td height="25"> 电子邮箱: 
                <input type="text" name="email" id="email" size="50" maxlength="75">
              </td>
            </tr>
            <tr> 
              <td height="25">你的主页: 
                <input type="text" name="homepage" id="homepage" size="50" maxlength="75">
              </td>
            </tr>
            <tr> 
              <td><br>
                <p class=center>你的留言:</p>
                <div align="center"> 
                  <textarea name="content" id="content" cols="60" rows="7" valign=top></textarea>
                </div>
              </td>
            </tr>
            <tr> 
              <td height="40"> 
                <div align="center"> 
                  <input type=submit value="我写好了,要发出去!" id=submit1 name=submit1>
                  &nbsp;&nbsp;&nbsp;&nbsp; 
                  <input type=reset value="填错了,再来一次" id=reset1 name=reset1>
                </div>
              </td>
            </tr>
          </table>
          </form>
<%

'================================================================================================
Case "add"
username = Trim(Request("username"))
content = Request("content")
'content = replace(content,"<","&lt;")
'content = replace(content,">","&gt;")

If username="" OR content="" Then
    '   如果姓名或者留言没写
    '   在这里显示错误信息
%>
          <p class=center><img src="images/wrong.gif" width="100" height="80" alt"错!"></p>
          <table align="center" border=2 bordercolordark="Blue" bordercolorlight="Navy" cellspacing=0 cellpadding=2 width=300>
            <tr>
              <td>
                <p class=center>朋友,我们不得不告诉你:<br><br>
                你的留言我们不能接受!<br><br>
                姓名和留言内容一定要写,OK?</p>
                <p class=center><a href="javascript:history.back()">回去再写一次吧 ^_^</a></p>
              </td>
            </tr>
          </table>
<%
Else
    'ConDule.Open "dule","sa","gbs108@www"
    
    address = Trim(Request("address"))
    ip = Request.ServerVariables("REMOTE_ADDR")
    email = Trim(Request("email"))
	createtime = FormatDateTime(Now)
    homepage = Trim(Request("homepage"))
    
    'If Request("usehtml")="text" Then
        ' 如果用户选择的是纯文本(text)
        ' 进行处理
        content = Replace(content,"&","&amp;")
        content = Replace(content,"<","&lt;")
        content = Replace(content,">","&gt;")
        content = Replace(content," ","&nbsp;")
        content = Replace(content,vbCrLf,"<br>")
    'End If

    sql = "Insert Into gbook (name,address,ip,email,homepage,time,content) Values('"_
            + sqlstr(username) + "','"_
            + sqlstr(address) + "','"_
            + sqlstr(ip) + "','"_
            + sqlstr(email) + "','"_
            + sqlstr(homepage) + "','"_
			+ sqlstr(createtime) + "','"_
            + sqlstr(content) + "')"
    ConDule.Execute( sql )
    
    ' 显示成功信息 
%>
          <p class=center><%= username %>,你好!谢谢你的宝贵留言。</p>
          <table align="center" border=2 cellpadding=4 cellspacing=0 width=400 bordercolorlight="#eeccff" bordercolordark="#eeccff">
            <tr>
              <td width=40>姓名</td>
              <td><%= username %></td>
            </tr>
            <% If address<>"" Then %>
            <tr>
              <td>地址</td>
              <td><%= address %></td>
            </tr>
            <% End If %>
            <% If email<>"" Then %>
            <tr>
              <td>电子信箱</td>
              <td><%= email %></td>
            </tr>
            <% End If %>
            <% If homepage<>"" Then %>
            <tr>
              <td>个人主页</td>
              <td><%= homepage %></td>
            </tr>
            <% End If %>
            <tr>
              <td>留言</td>
              <td><%= content %></td>
            </tr>
          </table>
          <p class=center><a href="guestbook.asp?job=display">现在就回去看看我的留言</a></p>
        <%
    'ConDule.Close
End If

'================================================================================================
Case "display"

'ConDule.Open "dule","sa","gbs108@www"
RecDule.Open "SELECT * FROM gbook WHERE show=1 ORDER BY id DESC",ConDule,3

PageSize = 10   '每页显示十条留言
RecDule.PageSize = PageSize
PageCount = RecDule.PageCount
RecordCount = RecDule.RecordCount

Page = CInt(Request("page"))
If Page<1 Then
    Page=1
ElseIf Page>PageCount Then
    Page=PageCount
End If
RecDule.AbsolutePage = Page

⌨️ 快捷键说明

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