挑战ASP问题!!ADODB.Recordset (0x800A0BB9)

<!--#includefile="conn.asp"--><%ifrequest("action")="reg"thensetrs=server.createobjec... <!--#i nclude file="conn.asp"-->
<%
if request("action")="reg" then
set rs=server.createobject("adodb.recordset")
rs.open "select * from user where name='"&trim(request("name"))&"'",conn,1,1
if rs.recordcount>0 then
response.write "<script language='javascript'>window.alert('您输入的用户名已存在,请返回重新输入!');history.back(-1);</script>"
response.end()
end if
sql="select * from user"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs.addnew
rs("name")=trim(request.form("name"))
rs("pwd")=trim(request.form("pwd"))
rs("wenti")=trim(request.form("wenti"))
rs("daan")=trim(request.form("daan"))
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript> alert('注册成功,点击确定立即登录!');location.replace('login.asp');</script>"
response.end
end if
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>用户注册</title>
</head>

<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>用户注册
<form name="form1" method="post" action="?action=reg" onSubmit="return chkform(this)">
<table width="347" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="142">用户名</td>
<td width="179"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>密码</td>
<td><input name="pwd" type="password" id="pwd"></td>
</tr>
<tr>
<td>密码提示问题</td>
<td><input name="wenti" type="text" id="wenti"></td>
</tr>
<tr>
<td>密码提示答案</td>
<td><input name="daan" type="text" id="daan"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="注册">
<input type="reset" name="submit" value="重置"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>

以上代码是注册登录系统中的一段,名为reg.asp,但运行的时候报错。数据库连接已经成功,我想要用户注册信息正确录入到数据库中,望不吝赐教!!
展开
 我来答
度老虎
推荐于2016-03-29 · TA获得超过1546个赞
知道大有可为答主
回答量:1661
采纳率:100%
帮助的人:2340万
展开全部
好多错误啊,我帮你改一下,你试试看:

<!--#include file="conn.asp"-->
<%
if request("action")="reg" then
username=replace(replace(trim(request("name")),"'","''")," ","")
password=trim(request.form("pwd"))
wenti=trim(request.form("wenti"))
daan=trim(request.form("daan"))
if username="" or password="" or wenti="" or daan="" then
conn.close
set conn=nothing
response.write "<script language=javascript> alert('资料不全,请重新填写!');history.back();</script>"
response.end
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from [user] where name='"&username&"'",conn,1,3
if not rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write "<script language='javascript'>window.alert('您输入的用户名已存在,请返回重新输入!');history.back(-1);</script>"
response.end
else
rs.addnew
rs("name")=username
rs("pwd")=password
rs("wenti")=wenti
rs("daan")=daan
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write "<script language=javascript> alert('注册成功,点击确定立即登录!');location.replace('login.asp');</script>"
response.end
end if
end if
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>用户注册</title>
</head>

<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>用户注册
<form name="form1" method="post" action="?action=reg" onSubmit="return chkform(this)">
<table width="347" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="142">用户名</td>
<td width="179"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>密码</td>
<td><input name="pwd" type="password" id="pwd"></td>
</tr>
<tr>
<td>密码提示问题</td>
<td><input name="wenti" type="text" id="wenti"></td>
</tr>
<tr>
<td>密码提示答案</td>
<td><input name="daan" type="text" id="daan"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="注册">
<input type="reset" name="submit" value="重置"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式