欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

一个BBS的源代码(四)

程序员文章站 2022-04-02 22:54:28
==============================case "write"============================== 发表文章%>
==============================
case "write"
==============================
发表文章

%>

<table align=center border=0 cellpadding=7 cellspacing=0 width=650>
<tr>
<td class=menu>
<p><a href="/">飞林庄</a>-&gt;<a href="<%= asp_file_name %>">经验交流</a></p>
<form action="<%= asp_file_name %>" id=form1 method=post name=form1>
<input type=hidden name=job value=add>
账号:<input id=userid maxlength=30 name=userid size=30>
密码:<input id=password name=password type=password><br>
题目:<input id=title maxlength=80 name=title size=72><br>
<textarea cols=80 id=content name=content rows=20></textarea><br>
<input id=mailme name=mailme value=yes type=checkbox style="border-bottom: #f0f0d0; border-left: #f0f0d0; border-right: #f0f0d0; border-top: #f0f0d0">有回复时发邮件通知我
<input type=submit value=" 发 表 ">
<input type=reset value=" 重 写 ">
</form>
</td>
</tr>
</table>


<%


================================
case "add","reply"
================================
把文章加进

检查数据
userid = trim(request("userid"))
password = trim(request("password"))
title = trim(request("title"))
content = rtrim(request("content"))
if request("mailme") = "yes" then mailme = 1 else mailme = 0

wrongmsg = ""
if userid = "" then wrongmsg = wrongmsg + "<dd><li>请输入你的账号。"
if password = "" then wrongmsg = wrongmsg + "<dd><li>请输入你的密码。"
if title = "\" then wrongmsg = wrongmsg + "<dd><li>请输入文章题目。"
if content = "" then wrongmsg = wrongmsg + "<dd><li>请输入内容。"

if wrongmsg = "" then

userid = sqlstr( userid )
password = sqlstr( password )
title = sqlstr( title )
content = sqlstr( content )

检察账号与密码
sql = "select count(*) from bbsmember where [账号]=" & userid & " and [密码]=" & password & ""
recmember.open sql , con , 1
if recmember.fields(0).value = 0 then memberexist = true else memberexist = false
recmember.close

if memberexist then

wrongmsg = wrongmsg + "<dd><li>用户名不存在或者密码不对。"

else 加进数据库

if job = "add" then
sql = "insert into bbs ([作者],[题目],[内容],[邮件通知]) values(" &_
sqlstr( userid ) & "," &_
sqlstr( title ) & "," &_
sqlstr( content ) & "," &_
mailme & ")"
else
回复文章数加一
con.execute( "update bbs set [回复]=[回复]+1 where [序号]=" & session("bbs_which") )


邮件通知原作者

sql = "select [题目],[时间],[邮件通知] from bbs where [序号]=" & session("bbs_which")
recbbs.open sql , con , 1
if recbbs.fields("邮件通知") then

firsttitle = recbbs.fields("题目")
writetime = recbbs.fields("时间")