|
- <?php
- /*
- * wechat 2.0
- * Copyright (c) 2016 yixi wei http://zhizhuchuxing.com/
- * Date: 2016.7.12
- * Something is to pay QQ1062140302
- */
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- date_default_timezone_set('PRC');
- $userid =1;//$_COOKIE['user_id'];
- $openid = 1;//$_COOKIE['open_id'];
- $id = isset($_POST['id'])?$_POST['id']:'0';
- $name = isset($_POST['name'])?$_POST['name']:'test';
- $phone = isset($_POST['phone'])?$_POST['phone']:'0';
- $id_type = isset($_POST['id_type'])?$_POST['id_type']:'0';
- $id_num = isset($_POST['id_num'])?$_POST['id_num']:'0';
- $reg = "/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/";
-
- if($id_num){
- if(!preg_match($reg,$id_num) && $id_type == 150){
- echo json_encode(array('code'=>'1','info'=>'身份证号码有误'));
- die;
- }
- if(!$name||!$id_type||!$id_num){
- echo json_encode(array('code'=>'1','info'=>'请填写完整信息'));
- die;
- }
- $sql = "update wechat_customer set name = '".$name."',id_type = '".$id_type."', id_num = '".$id_num."' where id =".$_POST['id'];
- $rs_u = $pdo->exec($sql);
-
- if(isset($rs_u) && !$rs_u){
- echo json_encode(array('code'=>'0','info'=>'信息修改'));
- die;
- }else{
- echo json_encode(array('code'=>'0','info'=>'信息已修改'));
- die;
- }
-
- }else{
- $sql = "select id,name,id_type,id_num from wechat_customer where id ='".$id."'";
- $rs = $pdo->query($sql);
- $rowset = $rs->fetchAll(PDO::FETCH_ASSOC);
- if(isset($rowset[0])){
- echo json_encode(array('code'=>'0','info'=>'0','list'=>$rowset[0]));
- }else{
- echo json_encode(array('code'=>'1','info'=>'未找到此条信息'));
- }
- }
-
|