新建二个文件.前端login.php.后端数据接收user.php
login.php
<script>
#### //收集数据 from email password
async function chech(btn){
const email =btn.form.email.value.trim();
const password =btn.form.password.value.trim();
#### //非空验证.加密提交
if(email.length>0 && password.lenght>0){
const response =await fetch(‘…/user.php’){
method:’post’,
headers;{
‘content-Type’:application/json’,
body:json.stringify({email,password})} }}
#### //解析数据
const data = await response.json();
}else{alert(邮箱及密码不能为空’);return false;}
</script>
user.php
$json = file_contents(‘php://input’);
$user = json_decode($json,true);
echo json_encode(#user);