注册页面Ajax检查用户名重复
注册页面Ajax检查用户名重复
IE现在60行报错:'null'为空或不是对象
上代码:
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> <script type="text/javascript"> var xmlHttp; function createXMLHTTP() { if(window.ActiveXObject) { var browseVersion=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"]; for(var i=0;i<browseVersion.length;i++) { xmlHttp=new ActiveXObject(browseVersion[i]); } } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); } if (!xmlHttp) { window.alert("不能创建XMLHttpRequest对象实例!"); return false; } } function $(id) { return document.getElementById(id); } function CheckUserName(obj,Msg) { if(obj.value=="") { alert( "请输入用户名!") } else { createXMLHTTP(); var url="chkuser.php?name=" + encodeURIComponent(obj.value); xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=IsExistUserName; xmlHttp.send(null); } } function IsExistUserName() { if(xmlHttp.readyState == 4) /*这是60行*/ { var isValid = xmlHttp.responseText; var exsits = document.getElementById("exsits"); exsits.innerHTML = isValid.substring(0,4); } } </script>
增加新用户 | |
用户名: | * |
密码: | * |
重复密码: | * |
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpinclude ('chek.php');include('../config.php');$name = $_GET[name];$sql="SELECT * FROM wyx_user WHERE wyx_name='$name'";[email protected]_query($sql)if($rs=mysql_fetch_array($sql)){ echo "用户名已存在";}else{ echo "可以注册";}?>