Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does ajax verify username and password

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces ajax how to verify the user name and password, the article is very detailed, has a certain reference value, interested friends must read it!

The details are as follows

1.ajax body part

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 ("Please enter user name and password!"); 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 ('wrong username or password!'); user= "; password="; return false } else {_ window.location.href= "index1.html";} xmlrequest.send ("user=" + user+ "& password=" + password);}

2.html code

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report