看看这个程序哪儿有问题,为什么连接不上数据库,运行不完呢!!

sunnyccc0000 2009-08-31 06:56:15
<!--#include file="conn.asp"-->
<html>
<head>
<title>验证</title>
</head>
<body>
<%
dim username,userPassword,email
username=Trim(request("username"))
userPassword=Trim(request("password"))
email=Trim(request("email"))
If(username=""or password=""or email="") Then
response.write "<script>alert(""用户名或密码或邮箱不能为空!"");</script>"
response.write "<script>history.go(-1);</script>"
response.end
else
If Request.Form1("Submitted") = "login.asp" Then
strsql="select * from user where user_name='"&username&"'"
strsql=strsql&"and user_pasw='"&password&"'"
strsql=strsql&"and user_email='"&email&"'"
set conn=server.CreateObject("adodb.connection")
conn.open "mydata"
set rs = CreateObject("ADODB.RecordSet")
rs.Open strsql,conn,1,3
if not rs.eof then
response.Write("用户名已经存在")
response.Redirect("index.asp")
response.End
else
rs.AddNew
rs("user_name")=request("username")
rs("user_pasw")=request("password")
rs("user_email")=request("email")
rs.update
response.Write("用户添加成功!")
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
end if
%>
</body>
</html>
...全文
89 点赞 收藏 8
写回复
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
凡夫与俗子 2009-09-01
判断if改成if username="" or userPassword="" or email="" then
回复
凡夫与俗子 2009-09-01
dim username,userPassword,email
username=Trim(request("username"))
userPassword=Trim(request("password"))
email=Trim(request("email"))
If(username=""or password=""or email="") Then
response.write " <script>alert(""用户名或密码或邮箱不能为空!""); </script>"
response.write " <script>history.go(-1); </script>"
response.end

你获取的username,userPassword,email和判断If(username=""or password=""or email="")根本没对牢嘛。所以永远执行这段代码了。
回复
sumjor 2009-09-01
<!--#include file="conn.asp"-->
<html>
<head>
<title>验证 </title>
</head>
<body>
<%
dim username,userPassword,email
username = Trim(request("username"))
password = Trim(request("password"))
email = Trim(request("email"))
If(username="" or password="" or email="") Then
response.write " <script>alert(""用户名或密码或邮箱不能为空!""); </script>"
response.write " <script>history.go(-1); </script>"
response.end
else
If Request("Submitted") = "login.asp" Then
strsql="select * from [user] where user_name='" & username & "'"
strsql=strsql & " and user_pasw='" & password & "'"
strsql=strsql & " and user_email='" & email & "'"
set conn=server.CreateObject("adodb.connection")
conn.open "mydata"
set rs = CreateObject("ADODB.RecordSet")
rs.Open strsql,conn,1,3
if not (rs.eof and rs.eof) then
response.Write("用户名已经存在")
'response.Redirect("index.asp")
response.End
else
rs.AddNew
rs("user_name")= username
rs("user_pasw")= password
rs("user_email")= email
rs.update
response.Write("用户添加成功!")
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
%>
</body>
</html>

这样呢?
回复
sunnyccc0000 2009-08-31
对啊!
控件名字没错
回复
hookee 2009-08-31
表单中控件的名字是不是 username password email?
回复
sunnyccc0000 2009-08-31
还是不行,只运行到“用户名或密码或邮箱不能为空”。
用户名,密码和邮箱都填上,也只弹出“用户名或密码或邮箱不能为空”对话框。连不上数据库啊
回复
hookee 2009-08-31

<!--#include file="conn.asp"-->
<html>
<head>
<title>验证 </title>
</head>
<body>
<%
dim username,userPassword,email
username = Trim(request("username"))
password = Trim(request("password"))
email = Trim(request("email"))
If(username="" or password="" or email="") Then
response.write " <script>alert(""用户名或密码或邮箱不能为空!""); </script>"
response.write " <script>history.go(-1); </script>"
response.end
else
If Request("Submitted") = "login.asp" Then
strsql="select * from user where user_name='" & username & "'"
strsql=strsql & " and user_pasw='" & password & "'"
strsql=strsql & " and user_email='" & email & "'"
set conn=server.CreateObject("adodb.connection")
conn.open "mydata"
set rs = CreateObject("ADODB.RecordSet")
rs.Open strsql,conn,1,3
if not (rs.eof and rs.eof) then
response.Write("用户名已经存在")
'response.Redirect("index.asp")
response.End
else
rs.AddNew
rs("user_name")= username
rs("user_pasw")= password
rs("user_email")= email
rs.update
response.Write("用户添加成功!")
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
%>
</body>
</html>
回复
liuwei_IT_love 2009-08-31
<!--#include file="conn.asp"-->
<html>
<head>
<title>验证 </title>
</head>
<body>
<%
dim username,userPassword,email
username=Trim(request("username"))
userPassword=Trim(request("password"))
email=Trim(request("email"))
If(username=""or password=""or email="") Then
response.write " <script>alert(""用户名或密码或邮箱不能为空!""); </script>"
response.write " <script>history.go(-1); </script>"
response.end
else
If Request.Form1("Submitted") = "login.asp" Then
strsql="select * from user where user_name='"&username&"'"
strsql=strsql&"and user_pasw='"&password&"'"
strsql=strsql&"and user_email='"&email&"'"
set conn=server.CreateObject("adodb.connection")
conn.open "mydata"
set rs = CreateObject("ADODB.RecordSet")
rs.Open strsql,conn,1,3
if not rs.bof and not rs.eof then
response.Write("用户名已经存在")
response.Redirect("index.asp")
response.End
else
rs.AddNew
rs("user_name")=request("username")
rs("user_pasw")=request("password")
rs("user_email")=request("email")
rs.update
response.Write("用户添加成功!")
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
end if
%>
</body>
</html>
应该是这样写吧,如果不行,再看看conn.asp与set conn=server.CreateObject("adodb.connection")
conn.open "mydata"
set rs = CreateObject("ADODB.RecordSet")
rs.Open strsql,conn,1,3
这段
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告