用户注册 已经提示注册成功,但是数据库里面没有内容

yukichan1 2010-12-23 02:14:31
正在做用户注册的页面。调试的时候已经提示注册成功了,但是数据库里没有新增的内容,数据库里的user_name,use_sex等等都是空白的。但是user_id是自动编号的,这一列却一直递增,那应该是数据库有收到我的注册吧,为什么其他列会没有内容呢?

请大家帮一下忙!谢谢!在线等~~

下面是代码:
<%
Function isvalidemail(user_mail)
Dim names,name,i ,c
isvalidemail=True
names=Split((user_mail),"@")
'字符串必须有"@"
If UBound(names)<> 1 Then
Isvalidemail=False
Exit function
End If

'检查是否有非法字符
For Each name In names
If Len(name)<= 0 Then
isvalidmail=False
Exit function
End If
For i = 1 To Len(name)
c=LCase(Mid(name,i,1))
If InStr("abcdefghijklmnopqrstuvwxyz_-.",c)<=0 And Not IsNumeric(c) Then
isvaildemail= False
Exit function
End If
Next
If Left(name,1)="·" Or Right(name,1)="." Then
isvalidemail=False
Exit function
End If
Next
i=Len(names(1))-instrrev(names(1),"·")
If i<>2 And i<>3 Then
isvalidmail=False
Exit function
End If
If InStr(user_email,".")>0 Then
Isvalidemail=False
Exit function
End If
End function
—————————以上是检测电子邮件的合法性————
founderr=flase
Function validdata()
Dim user_name,user_pass,user_pass2,user_sex,user_mail,user_adds,user_tel,user_postcode

'邮箱要正确
If isvalidemail(Trim(request.Form("user_mail")))=false Then
%>邮箱不正确<BR><%
founderr=True
Else
user_mail=Trim(request.Form("user_mail")) End If
'用户名不为空
If Trim(request.Form("user_name"))="" Then
%>用户名不能为空<br><%
founderr=True
Else
user_name=Trim(request.Form("user_name"))
End If
'用户名已被注册
Set rs=server.CreateObject("ADODB.Recordset")
sql="select * from user2 where user_name='"&user_name&"'"
rs.open sql,conn,3,3
If Not rs.eof Then
%>此用户名已被注册"<BR><%
founderr=True
End If
rs.close
Set rs=Nothing
'性别不为空
If Trim(request.Form("user_sex"))="" Then
%>性别不能为空<BR><%
founderr=True
Else
user_sex=Trim(request.Form("user_sex"))
End If
'密码正确
If Trim(request.Form("user_pass"))="" Or Trim(request.Form("user_pass2"))="" Or Trim(request.Form("user_pass"))<>Trim(request.Form("user_pass2")) Then
%>密码或确认密码不能为空<BR><%
founderr=True
Else
user_pass=Trim(request.Form("user_pass"))
End If
'地址不为空
If Trim(request.Form("user_adds"))="" Then
%>地址不能为空<BR><%
founderr=True
Else
user_adds=Trim(request.Form("user_adds")) End If

'电话必须不为空且为数字
If Trim(request.Form("user_tel"))="" Or Not IsNumeric(Trim(request.Form("user_tel")))Then
%>电话不能为空且必须全为数字<BR><%
founderr=True
Else
user_tel=Trim(request.Form("user_tel")) End If
'邮编不为空
If Trim(request.Form("user_postcode"))="" Then
%>邮编不能为空<BR><%
founderr=True
Else
user_postcode=Trim(request.Form("user_postcode")) End If
End Function
——————————————这部分是检查注册信息的合法性————
下面是添加数据到数据库
Call validdata
If founderr=true Then
%>
<table><tr>
<td>注册失败</td>
<td><a href="reg.asp">重新注册</a></td></tr>
</table>
<%
Else
Set rs=server.CreateObject("ADODB.Recordset")
sql="select * from user2"
rs.open sql,conn,1,3

'向数据库添加数据
rs.addnew
rs("user_name")=user_name
rs("user_pass")=user_pass
rs("user_adds")=user_adds
rs("user_sex")=user_sex
rs("user_tel")=user_tel
rs("user_postcode")=user_postcode
rs("user_mail")=user_mail
'更新数据库
rs.update
rs.close
Set rs=Nothing
'提示用户注册成功,并显示用户信息
%>
<table>
<td>注册成功</td><td>
<tr>
<td>
<a href="log.asp">马上登录</a>
</td>
</tr>
</table>

<% End if%>

...全文
1115 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yukichan1 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xming4321 的回复:]
Dim user_name,user_pass,user_pass2,user_sex,user_mail,user_adds,user_tel,user_postcode

是function内的变量


所以在外面不可见

然后
rs("user_name")=user_name
rs("user_pass")=user_pass
rs("user_adds")=user_……
[/Quote]


谢谢啊!!搞定了!
十一文 2010-12-23
  • 打赏
  • 举报
回复
Dim user_name,user_pass,user_pass2,user_sex,user_mail,user_adds,user_tel,user_postcode

是function内的变量


所以在外面不可见

然后
rs("user_name")=user_name
rs("user_pass")=user_pass
rs("user_adds")=user_adds
rs("user_sex")=user_sex
rs("user_tel")=user_tel
rs("user_postcode")=user_postcode
rs("user_mail")=user_mail

这里就全部为空罗


你应该吧这些变量放到外面


另楼主获取变量值 也最好在外面

函数最好只负责单一职责

28,391

社区成员

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

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