ASP问题(急)

来源:百度知道 编辑:UC知道 时间:2024/05/31 04:54:09
<%@language=vbscript%>
<!--#include file=conn.asp-->
<html>
<head>
</head>
<body bgcolor=#c1f7d8>
<center>
<%
dim strname,strpassword1
strname=request.form("name")
strpassword1=request.form("password1")
if strname=""then
response.write"账号不能为空<p></p>"
%>
<%
response.end
end if
strsql="select * from [user] where username='"&strname&"'"
set rs =server.createobject("adodb.recordset")
rs.open strsql,conn,1,3
if not rs.eof and not rs.bof then
response.write"你所用的账号已经存在,请修改账号<br><br>"
%>

<%
response.end
end if
rs.close
set rs=nothing
strtable="[user]"
set rs =server.createobject("adodb.recordset")
rs.open strtable,conn,1,3
rs.addnew
rs(&qu

strtable="[user]" 用 sqlstr="select * from user where 1=2" 代替
rs.open sqlstr,conn,3,3

加trim函数
strname=trim(request.form("name"))
strpassword1=trim(request.form("password1"))

我用SQL数据库,测试了一下楼主的这段代码,并没有什么错误,可以注册帐号!

<%
dim strname,strpassword1
strname=request.form("strname")
strpassword1 =request.form("strpassword1")
if strname="" then
response.write "<script>alert('帐号不能为空!');history.back()</script>"
response.end
end if

sql="select * from [user] where username='"&strname&"'"
set rs =server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if not rs.eof and not rs.bof then
response.write"你所用的账号已经存在,请修改账号<br><br>"
response.end
end if
rs.close
set rs=nothing
strtable="[user]&q