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

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>
...全文
125 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
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
这段

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧