用ASP Access制作论坛教程(3)

2008-02-23 09:33:41来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


detnew.asp


<%@LANGUAGE="VBSCRIPT" CODEPAGE="CP_ACP"%>
<!--#include virtual="adovbs.inc"-->
<%
    dbpath=server.MapPath("news.mdb")
    set conn=server.CreateObject("adodb.connection")
    conn.open"driver={Microsoft Access Driver (*.mdb)};dbq="&dbpath
    titleID=request("titleID")
    name=request("name")
    Email=request("Email")
    subject=request("subject")
    words=request("words")
    if subject="" or words="" or name="" or Email="" then
       outputmsg="字段不能为空,请填写完整信息!"
    else
       set rs=server.CreateObject("adodb.recordset")
       rs.open "details",conn,adopendynamic,adlockpessimistic
       rs.addnew
           rs("name")=name
           rs("Email")=Email
           rs("subject")=subject
           rs("words")=words
           rs("titleID")=titleID
       rs.update
       outputmsg="您的回复已加入!"
       session("name")=name
       session("Email")=Email
      sql="update titles set lastnewsdate=now(),shu=shu 1 where titleID="&clng(titleID)    
       conn.execute(sql)
    end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="1;URL=detail.asp?titleID=<%=titleID%>">
</head>
<body>
<center><%=outputmsg%></center>
</body>
</html>

detout.asp


<%
    sub detailoutput(rs)
       words=replace(server.HTMLEncode(" "&rs("words")),chr(13),"<br>")
       words=replace(words," ","&nbsp;")
       Email="<a href="""&rs("Email")&"mailto:"&rs("Email")&""">"&rs("Email")&"</a>"
%>
<center>
    <table>
       <tr>
           <td>作者:<%=rs("name")%></td>
           <td>Email:<%=Email%></td>
           <td>时间:<%=rs("newdate")%></td>
       </tr>
       <tr>
           <td colspan="3">主题:<%=rs("subject")%></td>
       </tr>
       <tr>
           <td colspan="3"><%=words%></td>
       </tr>
    </table>
</center>
<%
    end sub
%>

这个程序只是一个简单的范例,还有许多功能没有加入,只是给大家作为参考。

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:ASP应用中的应用函数

下一篇:关于session的几个补充函数