| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3152 人关注过本帖
标题:求助:注册时检测用户名是否可用?
取消只看楼主 加入收藏
suoyuan888
Rank: 2
等 级:论坛游民
帖 子:58
专家分:16
注 册:2009-8-24
结帖率:92.86%
收藏
已结贴  问题点数:15 回复次数:4 
求助:注册时检测用户名是否可用?
请高手指教:当点击检测用户名时,为什么没有反应,而在网页的左下角会出现,网页有错误的提示呢?
Userreg.html
<FORM name='UserReg' action='UserRegPost.asp' method='post'>
                          <table width=95% border=0 align="center" cellpadding=5 cellspacing=1 bordercolor="#FFFFFF" style="border-collapse: collapse">
                            <TR align=center>
                              <TD height=20 colSpan=2><b>新用户注册</b></TD>
                            </TR>
                            <TR>
                              <TD width="37%"><b>用户名:</b><BR>
                                不能小于4个字符(2个汉字)</TD>
                              <TD width="63%"> <INPUT   maxLength=14 size=30 name=UserName>
                                <font color="#FF0000">*</font>  <input name="Check" type="button" id="Check" value="检查用户名" onClick="checkreg();"></TD>
                            </TR>
                            <TR>
                              <TD width="37%"><B>密码(至少6位):</B><BR>
                                请输入密码,区分大小写。 不要使用类似 '*'、' '的特殊字符</TD>
                              <TD width="63%"> <INPUT   type=password maxLength=12 size=30 name=Password>
                                <font color="#FF0000">*</font> </TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>确认密码(至少6位):</strong><BR>
                              </TD>
                              <TD width="63%"> <INPUT   type=password maxLength=12 size=30 name=PwdConfirm>
                                <font color="#FF0000">*</font> </TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>密码问题:</strong><BR>
                                忘记密码的提示问题</TD>
                              <TD width="63%"> <INPUT   type=text maxLength=50 size=30 name="Question">
                                <font color="#FF0000">*</font> </TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>问题答案:</strong><BR>
                                忘记密码的提示问题答案,用于取回密码</TD>
                              <TD width="63%"> <INPUT   type=text maxLength=20 size=30 name="Answer">
                                <font color="#FF0000">*</font> </TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>性别:</strong><BR>
                                请选择您的性别</TD>
                              <TD width="63%"> <INPUT type=radio CHECKED value="1" name=sex>
                                男 &nbsp;&nbsp; <INPUT type=radio value="0" name=sex>
                                女</TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>Email地址:</strong><BR>
                                请输入有效的邮件地址</TD>
                              <TD width="63%"> <INPUT   maxLength=50 size=30 name=Email>
                                <font color="#FF0000">*</font></TD>
                            </TR>
                            <TR>
                              <TD><strong>公司网址:</strong></TD>
                              <TD width="63%"><INPUT name=homepage id="homepage" value="http://" size=30   maxLength=50></TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>公司名称:</strong><BR>
                                您的公司名称</TD>
                              <TD width="63%"> <INPUT name=CompanyName id="CompanyName" size=30   maxLength=100></TD>
                            </TR>
                            <TR>
                              <TD><strong>收货地址:</strong></TD>
                              <TD><INPUT name=Add id="Add" size=30   maxLength=100>
                                <font color="#FF0000">*</font></TD>
                            </TR>
                            <TR>
                              <TD><strong>收货人:</strong></TD>
                              <TD><INPUT name=Receiver id="Receiver" size=30   maxLength=100></TD>
                            </TR>
                            <TR>
                              <TD><strong>邮政编码:</strong></TD>
                              <TD width="63%"><input name=postcode id="postcode" size=30 maxlength=20>
                                <font color="#FF0000">*</font></TD>
                            </TR>
                            <TR>
                              <TD><strong>联系电话:<br>
                                </strong>格式010-81991660<strong> </strong></TD>
                              <TD width="63%"><input name=Phone id="Phone" size=30 maxlength=20>
                                <font color="#FF0000">*</font></TD>
                            </TR>
                            <TR>
                              <TD><strong>手机:</strong></TD>
                              <TD><input name=Mobile id="Mobile" size=30 maxlength=20></TD>
                            </TR>
                            <TR>
                              <TD width="37%"><strong>传 真:</strong></TD>
                              <TD width="63%"> <INPUT name=Fax id="Fax" size=30 maxLength=50></TD>
                            </TR>
                          </TABLE>
                  <div align="center">
                    <INPUT   type=submit value=" 注 册 " name=Submit>
                    &nbsp;
                    <INPUT name=Reset   type=reset id="Reset" value=" 清 除 ">
                  </div>
                </form>
                        <form name='reg' action='../UserCheckreg.asp' method='post' target='CheckReg'>
          <input type='hidden' name='username' value=''>
        </form><!-Plist_Bottom->


UserCheckRegl.asp
<!--#include file="Inc/conn.asp"-->
<!--#include file="Inc/function.asp"-->
<%
dim UserName,FoundErr,ErrMsg

UserName=trim(request("UserName"))
Response.Write(UserName)
if UserName="" or strLength(UserName)>14 or strLength(UserName)<4 then
    founderr=true
    errmsg=errmsg & "<br><li>请输入用户名(不能大于14小于4)</li>"
else
      if Instr(UserName,"=")>0 or Instr(UserName,"%")>0 or Instr(UserName,chr(32))>0 or Instr(UserName,"?")>0 or Instr(UserName,"&")>0 or Instr(UserName,";")>0 or Instr(UserName,",")>0 or Instr(UserName,"'")>0 or Instr(UserName,",")>0 or Instr(UserName,chr(34))>0 or Instr(UserName,chr(9))>0 or Instr(UserName,"?")>0 or Instr(UserName,"$")>0 then
        errmsg=errmsg+"<br><li>用户名中含有非法字符</li>"
        founderr=true
    end if
end if
if founderr=false then
    dim sqlCheckReg,rsCheckReg
    sqlCheckReg="select * from [User] where UserName='" & Username & "'"
    set rsCheckReg=server.createobject("adodb.recordset")
    rsCheckReg.open sqlCheckReg,conn,1,1
    if not(rsCheckReg.bof and rsCheckReg.eof) then
        founderr=true
        errmsg=errmsg & "<br><li>“" & UserName & "”已经存在!请换一个用户名再试试!</li>"
    else
    end if
    rsCheckReg.close
    set rsCheckReg=nothing
end if        
%>
<html>
<head>
<title>检查用户名</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="mt_style.css" type=text/css rel=stylesheet>
</head>

<body>
<br>
<%
if founderr=false then
    call Success()
else
    call WriteErrmsg()
end if
%>
</body>
</html>
<%
call CloseConn

sub WriteErrMsg()
    response.write "<table align='center' width='300' border='0' cellpadding='2' cellspacing='0' class='border'>"
    response.write "<tr class='title'><td align='center' height='15'>错误提示</td></tr>"
    response.write "<tr class='tdbg'><td align='left' height='100'>" & errmsg & "<p align='center'>【<a href='javascript:onclick=window.close()'>关 闭</a>】<br></p></td></tr>"
    response.write "</table>"
end sub

sub Success()
    response.write "<table align='center' width='300' border='0' cellpadding='2' cellspacing='0' class='border'>"
    response.write "<tr class='title'><td align='center' height='15'>恭喜你!</td></tr>"
    response.write "<tr class='tdbg'><td align='left' height='100'><br>“" & UserName & "”尚未被人使用,赶紧注册吧!<p align='center'>【<a href='javascript:onclick=window.close()'>关 闭</a>】<br></p></td></tr>"
    response.write "</table>"
end sub
%>
搜索更多相关主题的帖子: 用户名 注册 检测 
2010-01-06 14:32
suoyuan888
Rank: 2
等 级:论坛游民
帖 子:58
专家分:16
注 册:2009-8-24
收藏
得分:0 
回复 2楼 孤独冷雨
谢谢!
没看懂—— 不知道您写的代码应该放在我的页面的哪个位置?
2010-01-06 16:48
suoyuan888
Rank: 2
等 级:论坛游民
帖 子:58
专家分:16
注 册:2009-8-24
收藏
得分:0 
回复 3楼 aspic
这个函数没有找到—— 好像根本没有
2010-01-06 16:49
suoyuan888
Rank: 2
等 级:论坛游民
帖 子:58
专家分:16
注 册:2009-8-24
收藏
得分:0 
回复 7楼 孤独冷雨
呵呵,让版主见笑了,初来乍到,对ASP编程还不是很熟悉,希望在这里能得到大家的帮助。
这次版主的话看明白了,这就去试下!谢谢!
2010-01-07 17:41
suoyuan888
Rank: 2
等 级:论坛游民
帖 子:58
专家分:16
注 册:2009-8-24
收藏
得分:0 
回复 8楼 hmhz
这个验证,代码看似很简洁!谢谢!
2010-01-07 17:43
快速回复:求助:注册时检测用户名是否可用?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034403 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved