| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1197 人关注过本帖
标题:检测用户名是否存在的问题
只看楼主 加入收藏
liu_libra
Rank: 2
等 级:论坛游民
帖 子:153
专家分:20
注 册:2008-10-13
结帖率:72.22%
收藏
 问题点数:0 回复次数:4 
检测用户名是否存在的问题
用户前台
<td width="18%" height="20" align="right" bgcolor="#EEF7FF" class="STYLE4"><span class="STYLE1"> <span class="STYLE6">*</span> </span> 用 户 名:</td>
<td width="34%" align="left" bgcolor="#FFFFFF"><input name="username" type="text" id="username" maxlength="20" />
   <input type="button" name="Submit4" value="检测用户名" onClick="checkName()"></td>

checkName()代码:
<script language="javascript">
function checkName()
{
var NameStr=document.all.userame.value
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "UserCheckReg.asp?uName="+NameStr, false);
xmlhttp.send();
if(xmlhttp.ResponseText==1)
alert("用户名已经存在");
else
alert("可以使用!");
}
</script>


UserCheckReg.asp代码:
<script language="javascript">
function checkName()
{
var NameStr=document.all.userame.value
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "UserCheckReg.asp?uName="+NameStr, false);
xmlhttp.send();
if(xmlhttp.ResponseText==1)
alert("用户名已经存在");
else
alert("可以使用!");
}
</script>


在网上看到很多类似的代码,可放到我的程序里当点击“检查用户名”的按钮时一点反应也没有,各位帮我看看怎么回事?
搜索更多相关主题的帖子: 用户名 检测 
2008-10-25 14:08
liu_libra
Rank: 2
等 级:论坛游民
帖 子:153
专家分:20
注 册:2008-10-13
收藏
得分:0 
刚复制错了,重发一次问题
检测用户名是否存在的问题
用户前台
<td width="18%" height="20" align="right" bgcolor="#EEF7FF" class="STYLE4"><span class="STYLE1"> <span class="STYLE6">*</span> </span> 用 户 名:</td>
<td width="34%" align="left" bgcolor="#FFFFFF"><input name="username" type="text" id="username" maxlength="20" />
   <input type="button" name="Submit4" value="检测用户名" onClick="checkName()"></td>

checkName()代码:
<script language="javascript">
function checkName()
{
var NameStr=document.all.userame.value
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "UserCheckReg.asp?uName="+NameStr, false);
xmlhttp.send();
if(xmlhttp.ResponseText==1)
alert("用户名已经存在");
else
alert("可以使用!");
}
</script>


UserCheckReg.asp代码:
<!--#include file="conn.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
strsql="select * from users where username='"&request("uName")&"'"

rs.open strsql,conn,1,1
if rs.eof and rs.bof  then
response.write 0
else
response.write 1
end if
rs.close
set rs=nothing
%>
在网上看到很多类似的代码,可放到我的程序里当点击“检查用户名”的按钮时一点反应也没有,各位帮我看看怎么回事?
2008-10-25 14:10
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
程序代码:
checkName()代码:
<script language="javascript">
function $(id){return document.getElementById(id);}
function checkName(){ 
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    xmlhttp.open("GET", "UserCheckReg.asp?uName="+escape($("userame").value),true);
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState==4 && xmlhttp.status==200){alert(xmlhttp.responseText);}
    }
    xmlhttp.send(null); 
} 
</script> 


UserCheckReg.asp代码:
<!--#include file="conn.asp"--> 
<%
Response.ContentType = "text/html;charset=GB2312"
Response.Expires = 0 
Response.Expiresabsolute = Now() - 1 
Response.AddHeader "pragma","no-cache" 
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache"

if conn.execute("select count(*) from users where username='"&request("uName")&"'")(0)<>0 then 
    response.write "用户名 “"&request("uName")&"”已存在!" 
else 
    response.write "用户名 “"&request("uName")&"” 可以注册!"
end if 
%> 

[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2008-10-25 17:27
liu_libra
Rank: 2
等 级:论坛游民
帖 子:153
专家分:20
注 册:2008-10-13
收藏
得分:0 
谢谢楼上版主支持,可怎么还是没反应啊,唉,有个错误提示也好啊!
2008-10-26 01:14
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
程序代码:
checkName()代码:
<script language="javascript">
function $(id){return document.getElementById(id);}
function checkName(){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    xmlhttp.open("GET","UserCheckReg.asp?uName="+escape($("userame").value),false); 
    xmlhttp.send(null);
    alert(xmlhttp.responseText); 
} 
</script> 


UserCheckReg.asp代码:
<!--#include file="conn.asp"--> 
<%
Response.ContentType = "text/html;charset=GB2312"
Response.Expires = 0 
Response.Expiresabsolute = Now() - 1 
Response.AddHeader "pragma","no-cache" 
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache"

if conn.execute("select count(*) from users where username='"&request("uName")&"'")(0)<>0 then 
    response.write "用户名 “"&request("uName")&"”已存在!" 
else 
    response.write "用户名 “"&request("uName")&"” 可以注册!"
end if 
%> 

[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2008-10-26 08:09
快速回复:检测用户名是否存在的问题
数据加载中...
 
   



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

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