html结构
<body>
<input type="text" name="" id="one" /><br />
<input type="password" name="" id="two" /><br />
<input type="button" value="发送" id="three" onclick="fn1()" /><br />
</body>
js交互
<script>
class Fn {
static get(url, obj, fn) {
Fn.http("get", url, obj, fn);
}
static post(url, obj, fn) {
Fn.http("post", url, obj, fn);
}
static http(type, url, obj, fn) {
let str = "";
for (let key in obj) {
str += key + "=" + obj[key] + "&";
}
str = str.slice(0, str.length - 1);
let xhr = new XMLHttpRequest();
url = type == "get" ? url + "?" + str : url;
xhr.open(type, url);
type == "post" &&
xhr.setRequestHeader(
"content-type",
"application/x-www-form-urlencoded"
);
xhr.send(type == "post" && str);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
fn(xhr.response);
}
};
}
}
function fn1() {
let a = one.value;
let b = two.value;
console.log(a, b);
Fn.post(
"002.PHP",
{
name: "abc",
age: "123",
},
(res) => {
if (res == "yes") {
location.href = "http://pengzhiqiang.host3v.com/";
}
}
);
}
</script>
<?PHP
$one=$_POST['name'];
$two=$_POST['age'];
$three='abc';
$four='123';
if($one==$three&&$two==$four){
echo 'yes';
}else{
echo 'no';
}
?>
结合Bootstrap,可以实现美观的登陆效果。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。