注册 登录
编程论坛 ASP技术论坛

做的注册页面怎么不调用检查保存页面?

cilubutong 发布于 2008-11-27 11:46, 2374 次点击
register.asp 注册页面
<html>
<head>
<title>新用户注册----在线考试系统</title>
</head>
<body>
<form name="form1" method="post" action="register.asp?action=usersave">
  <!--#include file="conn.asp"-->
  <style type="text/css">
<!--
.STYLE5 {font-size: 12px}
-->
  </style>
  <table width="269" height="110" border="0" align="center">
    <tr>
      <td width="109" class="STYLE5 STYLE5">用户名:</td>
      <td width="150"><input name="nam" type="text" class="text" id="nam"></td>
    </tr>
    <tr>
      <td class="STYLE5">密码:</td>
      <td><input name="pwd" type="password" class="text" id="pwd"></td>
    </tr>
    <tr>
      <td class="STYLE4"><span class="STYLE5">请再次输入密码:</span></td>
      <td><input name="pwd1" type="password" class="text" id="pwd1"></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center" class="STYLE1">
        <input name="Submit" type="submit" value="确认">
        <input type="submit" name="Submit2" value="返回">
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
usersave.asp页面
<!--#include file="conn.asp"-->
<%
    
  If Request("action") = "usersave" Then
        Call usersave()
     End If
  %>
<%
Sub usersave()
    dim nam
    dim pwd
    dim pwd1
    nam=trim(request.Form("nam"))
    pwd=trim(request.Form("pwd"))
    pwd1=trim(request.Form("pwd1"))
    if nam="" then
    response.Write"<script>alert('请输入用户名!');histroy.go(-1);</script>"
    response.End
    elseif pwd="" or pwd1=""then
    response.Write"<script>alert('请输入密码!');history.go(-1);</script>"
    response.End
    elseif pwd<>pwd1 then
    response.Write"<script>alert('两次输入的密码不一样!')history.go(-1);</script>"
    response.End
    elseif len(pwd)< 6 or len (pwd1)<6 then
    response.Write"<script>alert('密码不能少于6位')history.go(-1);</script>"
    response.End
    else
    set rs=server.CreateObject("ADODB.Recordset")
    sql="select * From student Where stuname='"&nam&"'"
    rs.open sql,conn,3,3
    if not rs.EOF then
    response.Write"<script>alert('该帐号已被注册')history.go(-1);</script>"
    response.End
    else
    rs.addnew
    rs("stuname")=nam
    rs("pwd")=pwd
    rs.update
    response.Redirect("index.asp")
    end if
    end if
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing
    end sub
    %>

[[it] 本帖最后由 cilubutong 于 2008-11-27 11:47 编辑 [/it]]
23 回复
#2
cilubutong2008-11-27 12:06
有哪个大哥知道的吗>?帮帮我!
#3
hmhz2008-11-27 12:27
<form name="form1" method="post" action="register.asp?action=usersave">
中的register.asp 改成 usersave.asp
查找问题需要去理解程序运行的逻辑去逐一找出问题所在!
#4
cilubutong2008-11-27 14:45
以下是引用hmhz在2008-11-27 12:27的发言:


中的register.asp 改成 usersave.asp
查找问题需要去理解程序运行的逻辑去逐一找出问题所在!

照你的方法改了,但是还是不行,我的程序写的有错误吗?
#5
yms1232008-11-27 15:10
<form name="form1" method="post" action="usersave.asp?action=usersave">
  </style>
  <table width="269" height="110" border="0" align="center">
    <tr>
      <td width="109" class="STYLE5 STYLE5">用户名:</td>
      <td width="150"><input name="nam" type="text" class="text" ></td>
    </tr>
    <tr>
      <td class="STYLE5">密码:</td>
      <td><input name="pwd" type="password" class="text" ></td>
    </tr>
    <tr>
      <td class="STYLE4"><span class="STYLE5">请再次输入密码:</span></td>
      <td><input name="pwd1" type="password" class="text" ></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center" class="STYLE1">
        <input name="Submit" type="submit" value="确认">
        <input type="submit" name="Submit2" value="返回">
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
#6
cilubutong2008-11-27 15:41
以下是引用yms123在2008-11-27 15:10的发言:


  
  
   
      用户名:
      
   
   
      密码:
      
   
   
      请再次输入密码:
      
   
   
      
        
        
      
   
  


 

我怎么点击那个确认它就不返回到注册页面,程序只执行到if nam="" then
    response.Write"<script>alert('请输入用户名!');histroy.go(-1);</script>"
    response.End
就不执行程序了
#7
chinasj2008-11-27 16:46
<html>
<head>
<title>新用户注册----在线考试系统</title>
</head>
<body>
<form name="form1" method="post" action="?action=usersave">
  <!--#include file="conn.asp"-->
  <style type="text/css">
<!--
.STYLE5 {font-size: 12px}
-->
  </style>
  <table width="269" height="110" border="0" align="center">
    <tr>
      <td width="109" class="STYLE5 STYLE5">用户名:</td>
      <td width="150"><input name="nam" type="text" class="text" id="nam"></td>
    </tr>
    <tr>
      <td class="STYLE5">密码:</td>
      <td><input name="pwd" type="password" class="text" id="pwd"></td>
    </tr>
    <tr>
      <td class="STYLE4"><span class="STYLE5">请再次输入密码:</span></td>
      <td><input name="pwd1" type="password" class="text" id="pwd1"></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center" class="STYLE1">
        <input name="Submit" type="submit" value="确认">
        <input type="submit" name="Submit2" value="返回">
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
usersave.asp页面
<!--#include file="conn.asp"-->
<%
   
  If Request("action") = "usersave" Then
        Call usersave()
     End If
  %>
<%
Sub usersave()
    dim nam
    dim pwd
    dim pwd1
    nam=trim(request.Form("nam"))
    pwd=trim(request.Form("pwd"))
    pwd1=trim(request.Form("pwd1"))
    if nam="" then
    response.Write"<script>alert('请输入用户名!');histroy.go(-1);</script>"
    response.End
    elseif pwd="" or pwd1=""then
    response.Write"<script>alert('请输入密码!');history.go(-1);</script>"
    response.End
    elseif pwd<>pwd1 then
    response.Write"<script>alert('两次输入的密码不一样!');history.go(-1);</script>"
    response.End
    elseif len(pwd)< 6 or len (pwd1)<6 then
    response.Write"<script>alert('密码不能少于6位');history.go(-1);</script>"
    response.End
    else
    set rs=server.CreateObject("ADODB.Recordset")
    sql="select * From student Where stuname='"&nam&"'"
    rs.open sql,conn,3,3
    if not rs.EOF then
    response.Write"<script>alert('该帐号已被注册')history.go(-1);</script>"
    response.End
    else
    rs.addnew
    rs("stuname")=nam
    rs("pwd")=pwd
    rs.update
    response.Redirect("index.asp")
    end if
    end if
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing
    end sub
    %>
#8
cilubutong2008-11-27 18:28
回复 第7楼 chinasj 的帖子
大哥根据你的程序也不可以的啊!
#9
yms1232008-11-27 19:37
以下是引用cilubutong在2008-11-27 15:41的发言:


我怎么点击那个确认它就不返回到注册页面,程序只执行到if nam="" then
    response.Write"alert('请输入用户名!');histroy.go(-1);"
    response.End
就不执行程序了

有数据?
#10
cilubutong2008-11-27 19:48
回复 第9楼 yms123 的帖子
没有数据到数据库中
#11
yms1232008-11-27 19:56
以下是引用cilubutong在2008-11-27 19:48的发言:

没有数据到数据库中

我是说 nam变量是否接收到数据
    response.Write"<script>alert('请输入用户名!');histroy.go(-1);</script>"
    response.End
到这句话证明应该是执行了response.end所以if判断生效了。
#12
谁与争疯2008-11-27 19:56
请试一试在面页中输出如下字段进行调试。
nam=trim(request.Form("nam"))
    pwd=trim(request.Form("pwd"))
    pwd1=trim(request.Form("pwd1"))

请输出以下字段的内容,然后再告诉我一下
nam,pwd,pwd1
#13
cilubutong2008-11-27 20:23
回复 第12楼 谁与争疯 的帖子
输入了没有任何反映噢!
#14
cilubutong2008-11-27 20:28
回复 第11楼 yms123 的帖子
我不输入密码和用户名点注册 就显示无法显示了
#15
谁与争疯2008-11-27 20:31
我的意思是,你输出你获取到的nam,pwd,pwd1 看看是否有内容?
#16
cilubutong2008-11-27 20:55
回复 第15楼 谁与争疯 的帖子
没有东西
#17
谁与争疯2008-11-27 21:25
从注册页面提交过来的记录,是空?
#18
cilubutong2008-11-27 22:34
回复 第17楼 谁与争疯 的帖子
恩!那个usersave页面根本就没有执行!
#19
谁与争疯2008-11-27 22:48

为什么你表单 提交 的页面和 获取 的页面,文件名不一样?
<form name="form1" method="post" action="register.asp?action=usersave">

你在usersave.asp页面进行获取表单的数据,为什么你要提交到register.asp?
你用?action来进行动作判断这个没错。
#20
谁与争疯2008-11-27 23:05

if nam=""
asp的赋值和判断都用 =  而不是 = ,==     ??
#21
aspic2008-11-29 21:38
数据的验证尽量在客户端 减少对服务器的访问
#22
谁与争疯2008-11-29 22:42
但,为了安全度提高些,服务器端最好也要验正数据值的正误和替换。
#23
lishizhong_8992008-11-30 12:42
回复 楼主 cilubutong 的帖子
你写到数据库中去就行啦
#24
hmhz2008-11-30 13:42
usersave.asp页面
<!--#include file="conn.asp"-->
<%
dim nam,pwd,pwd1
nam=trim(request.Form("nam"))
pwd=trim(request.Form("pwd"))
pwd1=trim(request.Form("pwd1"))
If Request("action") = "usersave" Then
   Call usersave(nam,pwd,pwd1)
End If

Sub usersave(nam,pwd,pwd1)
if nam="" then
    response.Write"<script>alert('请输入用户名!');histroy.go(-1);</script>"
elseif pwd="" or pwd1="" then
    response.Write"<script>alert('请输入密码!');history.go(-1);</script>"
elseif pwd<>pwd1 then
    response.Write"<script>alert('两次输入的密码不一样!')history.go(-1);</script>"
elseif len(pwd)<6 or len(pwd1)<6 then
    response.Write"<script>alert('密码不能少于6位')history.go(-1);</script>"
else
    set rs=server.CreateObject("ADODB.Recordset")
    rs.open "select * From student Where stuname='"&nam&"'",conn,3,3
    if not(rs.eof and rs.bof) then
        response.Write"<script>alert('该帐号已被注册')history.go(-1);</script>"
    else
        rs.addnew
        rs("stuname")=nam
        rs("pwd")=pwd
        rs.update
        response.Redirect("index.asp")
    end if
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing
end if
end sub
%>

[[it] 本帖最后由 hmhz 于 2008-11-30 13:44 编辑 [/it]]
1