public function posttest(){ $url1 = "http://127.0.0.28/plugin/test/index/rfid"; $post_data = array( '学校ID' => '1', '卡ID' => '2', ); $common = new Common(); $result = $common->postCurl($url1,$post_data); $result_json = json_decode($result); echo 'code:'.$result_json->code.' <br> msg:'.(string)$result_json->msg; echo("<script>console.log('".json_encode($result)."');</script>"); echo("<script>console.log('".json_encode($result_json)."');</script>"); } public function rfid(){ $postStr = input('post.'); $query = Db::name("core_cache"); $where['key'] = 'RFID'; $data['value'] = serialize($postStr); $res = $query->where($where)->update($data); if($res){ echo json_encode(array('code' => '200', 'msg' => 'ok.')); }else{ echo json_encode(array('code' => '400', 'msg' => 'error')); } }
数据库能写入POST过来的信息了:
a:2:{s:8:"学校ID";s:1:"1";s:5:"卡ID";s:1:"2";}
然后怎么返回code ?
0.话题发布后没及时显示,请联系官方QQ群管理;
1.话题支持代码,qq截屏直接粘贴,和QQ群一样;
2.问题描述清,比如服务器版本,程序版本;
3.能上代码,就不用文字;
4.把问题发到话题后再发QQ群;
5.如果感觉回复者解答的不错,可以发红包!
6.多帮助别人也是对自己的锻炼!
7.付费讨论中只有提问者和付费用户才可以查看回复
1.评论积分+1;每天最多10次奖励
2.发布话题积分+1;每天最多5次奖励
3.垃圾评论积分-500;
4.黄色,暴力,违反我国法律评论直接封号