1.微信小程序
Page({
data: {
},
onLoad: function (options) {
wx.request({
url: '',//开发者服务器接口地址
method: 'POST',
header: {
'content-Type': 'application/x-www-form-urlencoded'//content-type 默认为 application/json
},
data: {
something1: post_data,
},
success(res) {
console.log(res.data);//返回数据内容
}
})
},
})
2.PHP
<?php
$something1=$_POST['something1'];
$mydbhost = "";//ip
$mydbuser = "";//数据账户库名
$mydbpass = '';//登录密码
$dbname = "";//表名
$conn = mysqli_connect($mydbhost, $mydbuser, $mydbpass, $dbname);
if (!$conn) {
die("连接失败: " . mysqli_error($conn));
}
$q="'";//SQL语句
$con->query('SET NAMES UTF8');
$result = $con->query($q);// 执行 sql
if ($row = mysqli_fetch_array($result)) {
echo $row['admin'] ;//返回结果
}
$con->close();
?>