<?php $link=mysqli_connect('localhost','root','','a'); //然后是指定php链接数据库的字符集 mysqli_set_charset($link,'utf8'); if(empty($_POST['phone'])) { return "请输入手机号"; } if(empty($_POST['pwd'])) { return "请输入密码"; } $phone=$_POST['phone']; $pwd=md5($_POST['pwd']); $sql = "INSERT INTO php_user(phone,pwd) VALUES ('{$phone}','{$pwd}')"; $code=mysqli_query($link,$sql); echo json_encode(["coee"=>200,"msg"=>'保存成功']);