Get the App
SLTechnology News&Howtos  ›  Development  › 

How does ajax verify username and password

Shulou Source: shulou.com Published: 2022-06-03 20:17:05 11月12日 Update

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

Tags: Password user name content authentication article subject code value interest name buddy partner data database more knowledge industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info NVidia Xiaomi Huawei