自动检查用户名的问题
<script language="javascript" type="text/javascript">var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
var u_name = document.getElementById("u_name").value;
if ((u_name == null) || (u_name == "")) return;
var url = "cu.asp?name=" + escape(u_name);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState < 4) {
emailts.innerHTML="系统将自动检测您的用户名是否已被注册,请稍候...";
}
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
if (response=="true"){
emailts.innerHTML='恭喜你,用户名还未被注册!';
emailts.className="showok";
}
else{
emailts.innerHTML='对不起,用户名已被注册!';
emailts.className="showno";
}
}
}
</script>
<style type="text/css">
<!--
.showno {
color: #FF0000;
font-weight: bold;
background:url("note_error.gif") no-repeat 12px center;
padding-left:35px;
}
.showok {
color: #FF0000;
font-weight: bold;
background:url("note_ok.gif") no-repeat 12px center;
padding-left:35px;
}
-->
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" width="694" border="0">
<tbody>
<tr>
<td width="179" height="40" align="right" class="F14">用户名:</td>
<td width="168"><input id="u_name" onChange="callServer();" style="WIDTH: 155px" />
</td>
<td width="347"> <div id="emailts"></div></td>
</tr>
<tr>
<td height="40" align="right" class="F14">Email地址:</td>
<td colspan="2"><input id="email" style="WIDTH: 155px" /> </td>
</tr>
</tbody>
</table>
cu.asp
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "No-Cache"
%>
<!--#include file="conn.asp"-->
<%
name1=request.querystring("name")
response.write name1
response.end
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from u_ser where u_name='"&name&"'"
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
response.write("true")
else
response.write("false")
end if
rs.close
set rs=nothing
call CloseDatabase
%>
上面代码,我执行,总是提示,,对不起,用户名已被注册
我在 cu.asp 页面输出 name 页面提交的值根本就是到 cu.asp 处理页。。怎么回事哦。