Blogger Information
Blog 25
fans 0
comment 0
visits 9278
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1125用户登录表单数据的前端处理与后端PHP处理流程,要求画图,并用代码完整演示,附上图,再发布到作用中
P粉114035831
Original
490 people have browsed it

新建二个文件.前端login.php.后端数据接收user.php

1.文件

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>

2.文件

user.php

//获取文本流数据

$json = file_contents(‘php://input’);

//转为字符串.数据类型

$user = json_decode($json,true);

//验证返回json

echo json_encode(#user);

显示图

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!