Discuz!NT官方社区

首页 » Discuz!NT开发与测试 » Discuz!NT整合 » 我也发个简单的asp整合论坛的方法
sdxlh007 - 2007-12-6 1:43:00
用此方法整合需要在论坛后台关闭登录问答与验证码功能,原理和各位大侠的差不多

本来想用get方式提交。。没想到论坛不支持get方式。。只好做两表单提交了

一共两个文件

第一个文件: login.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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=utf-8" />
<title>登录</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="checklogin.asp">
用户名:<input name="username" type="text" id="username" /><br />
密码:<input name="password" type="password" id="password" /><br />
<input type="radio" name="expires" value="5256000" />永远
<input name="expires" type="radio" value="43200" />一个月
<input type="radio" name="expires" value="1440" />一天
<input type="radio" name="expires" value="60" />一小时
<input type="radio" name="expires" value="0" checked="checked" />浏览器进程
<input type="hidden" name="reurl" value="这里写你要转向到的网址" />
<input name="login" type="submit" id="login" value="登录" />
</form>
</body>
</html>


第二个文件: checklogin.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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>
'''''''''''''''''''这里是md5加密文件''''''''''''''网上到处都有。。大家可以自己去下载
<!-- #include file="md5code.asp" -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>验证登录</title>
</head>

<body>
<%
u_name=request("username")
u_psw=request("password")
ck=request("expires")
reurl=request("reurl")
sql="select * from bbst_users where username='" & u_name & "' and password='" & md5(u_psw) & "'"

strsql="provider=microsoft.jet.oledb.4.0;data source=你数据库的地址" '如果你的数据库是access的话用这段话
strsql="Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=discuzDB;Data Source=localhost;Connect Timeout=45" '如果你的数据库是sql server的话用这段

conn.open strsql

set rs=conn.execute(sql)
if not rs.eof then
  islogin="yes"
end if
rs.close
set rs=nothing
if islogin<>"yes" then
        response.write "登录失败"
        response.end
else
%>
<form id="form1" name="form1" method="post" action="写你论坛的地址(可以用相对路径也可以用绝对路径)/login.aspx">
<input name="username" type="hidden" id="username" value="<%=u_name%>" /><br />
<input name="password" type="hidden" id="password" value="<%=u_psw%>" /><br />
<input type="hidden" name="expires" value="<%=expires%>" />
<input type="hidden" name="reurl" value="<%=reurl%>" />
</form>
<script type="text/javascript">form1.submit();</script>
<%
end if
%>
</body>
</html>


cnlnol - 2007-12-6 9:23:00
能不能说下这两个文件
都改哪
除了数据库连接
应该放在哪个目录
新手:-|
www.gkzz.net - 2007-12-6 10:00:00
楼主说得不清不楚,让人措不着头脑!
sdxlh007 - 2007-12-6 12:07:00
这两个文件放在你网站的目录下就可以了
要改的地方文件代码里不是写清楚了吗。。。
login.asp要改的地方

<input type="hidden" name="reurl" value="这里写你要转向到的网址" />


checklogin.asp要改的地方,一个是数据库连接字符串,
一个是表单form标签

<form id="form1" name="form1" method="post" action="写你论坛的地址(可以用相对路径也可以用绝对路径)/login.aspx">


binghe - 2007-12-8 6:30:00
楼主能不能说的再详细一点啊??


整个是论坛的数据库还是网站的??

strsql="provider=microsoft.jet.oledb.4.0;data source=你数据库的地址" '如果你的数据库是access的话用这段话
strsql="Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=discuzDB;Data Source=localhost;Connect Timeout=45" '如果你的数据库是sql server的话用这段


下面这个我也不能理解。

<form id="form1" name="form1" method="post" action="写你论坛的地址(可以用相对路径也可以用绝对路径)/login.aspx">


sdxlh007 - 2007-12-8 23:08:00
回楼上的:

数据库随便是你网站的或是论坛的
但是网站的用户表要和论坛的用户表为同一数据库的同一张表
如果你的网站用户表不是论坛的用户表。那想要关联就必须使用户注册名与用户密码与论坛的一致才可以了
而且下面这段代码要写两次,以sql server2000数据库为例,我的网站数据库与论坛数据库为分开的两个独立数据库,用户表也是分别两个数据库的用户表,则代码为如下:
我将网站数据库名为:web_db,数据库角色的用户名为web_user,密码为:web_password
论坛数据库名为:bbs_db,论坛角色的用户名为bbs_user,密码为:bbs_password

dim conn,conn_bbs
web_strsql="Provider=SQLOLEDB.1;Password=web_password;Persist Security Info=True;User ID=web_user;Initial Catalog=web_db;Data Source=localhost;Connect Timeout=45"
bbs_strsql="Provider=SQLOLEDB.1;Password=bbs_password;Persist Security Info=True;User ID=bbs_user;Initial Catalog=bbs_db;Data Source=localhost;Connect Timeout=45"
conn.open web_strsql
conn_bbs.open bbs_strsql


然后分别对两张用户表进行验证用户名与密码,比较麻烦
个人还是推荐网站用户表与论坛数据库合并,同时使用论坛用户表。


第二个你不能理解的问题我不知道是我表达的有问题还是你理解的有问题。。。
给你个例子,比如,我的论坛地址为:http://bbs.abc.com/,则代码应该是这样

<form id="form1" name="form1" method="post" action="http://bbs.abc.com/login.aspx">


或,我网站与论坛使用的是一个域名http://www.abc.com,论坛放在网站的bbs目录中,代码如下:

<form id="form1" name="form1" method="post" action="/bbs/login.aspx">




<form id="form1" name="form1" method="post" action="http://www.abc.com/bbs/login.aspx">


不知道这样你明白没有。。。。
py109 - 2007-12-9 9:14:00
搂主辛苦了,请问用什么CMS啊???:~
青云 - 2007-12-9 14:00:00
强烈支持楼主,希望早日完善同步退出功能!
对了,问一句这个办法可以把NT与ECSHOP整合在一起么?
binghe - 2007-12-9 17:27:00


引用:
原帖由 sdxlh007 于 2007-12-8 23:08:00 发表
回楼上的:

数据库随便是你网站的或是论坛的
但是网站的用户表要和论坛的用户表为同一数据库的同一张表
如果你的网站用户表不是论坛的用户表。那想要关联就必须使用户注册名与用户密码与论坛的一致才可以了
而......


多谢指点。。够详细的。。呵呵
sdxlh007 - 2007-12-9 18:29:00
回7楼:

我不用CMS。。。我比较喜欢自己做站。。自己写的代码改起来比较方便

回8楼:
这种方法理论上可以与别的系统整合。。。不过代码部份要适当的改改,原理是一样的
shavie - 2007-12-9 20:17:00
收藏了!
syslogin - 2007-12-12 10:18:00
说来说去 还是个表单自动提交~
1
查看完整版本: 我也发个简单的asp整合论坛的方法