web前端|js教程
ajax,实例,密码
web前端-js教程
这篇文章主要为大家详细介绍了ajax验证用户名和密码的实例代码,感兴趣的小伙伴们可以参考一下
源码之家官网qq聊天系统,ubuntu 版本有哪些,Tomcat v8.0一闪,爬虫病毒怎么删除,php页面交互单元测试,成刚seolzw
本文实例为大家介绍了ajax验证用户名和密码的具体代码,供大家参考,具体内容如下
手机版电影系统源码,ubuntu硬盘不识别,爬虫用什么程序,php 5升级php7,动态加载seolzw
1.ajax主体部分
jquery 事件源码定位,老挑毛ubuntu,tomcat打开显示警告,爬虫 招投标,php路由教程学习,平湖一站式seo推广大概是什么lzw
var xmlrequest;function createXMLHttpRequest(){if(window.XMLHttpRequest){ xmlrequest=new XMLHttpRequest();}else if(window.ActiveXObject){ try{ xmlrequest=new ActiveXObject("Msxm12.XMLHTTP"); } catch(e){ try{ xmlrequest=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){} } }}function login(){ createXMLHttpRequest(); var user = document.getElementById("yhm").value; var password = document.getElementById("mm").value; if(user==""||password==""){ alert("请输入用户名和密码!"); return false; } var url = "check.php?user="+user+"&password="+password; xmlrequest.open("POST",url,true); xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlrequest.onreadystatechange = function(){ if(xmlrequest.readyState == 4){ if(xmlrequest.status==200){var msg = xmlrequest.responseText; if(msg==1){ alert(用户名或密码错误!); user=""; password=""; return false;} else{window.location.href="index1.html";} } } } xmlrequest.send("user="+user+"&password="+password); }
2.html代码
3.这里用的是sha1加密,把你的密码和数据库名称修改成你自己的即可
query($query);$num=$result->num_rows;if(!$num){ echo "1";} $dp->close(); ?>
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
ajax文件上传成功 解决浏览器兼容问题
laypage前端分页插件实现ajax异步分页
Ajax发送和接收二进制字节流数据的方法