|
- <?php
- /*
- * wechat 2.0
- * Copyright (c) 2016 yixi wei http://zhizhuchuxing.com/
- * Date: 2016.7.12
- * Something is to pay QQ1062140302
- */
- header("Access-Control-Allow-Origin:*");
- date_default_timezone_set('PRC');
- $userid =$_COOKIE['user_id'];
- $openid = $_COOKIE['open_id'];
- $id = isset($_POST['id'])?$_POST['id']:'0';
- $name = isset($_POST['name'])?$_POST['name']:'0';
- $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(!preg_match($reg,$id_num) && $id_type ==150){
- // echo json_encode(array('code'=>'1','info'=>'身份证号码有误'));
- // die;
- //}
- if(!$name||!$id_type){
- echo json_encode(array('code'=>'1','info'=>'请填写完整信息'));
- die;
- }
- if($id){
- $sql = "update wechat_customer set name = '".$name."',id_type = '".$id_type."', id_num = '".$id_num."' where id =".$_POST['id'];
- }else{
- $sql = "insert into wechat_customer(`name`,`phone`,`id_type`,`id_num`,`wechat_user_id`,`wechat_open_id`)"
- . " values('".$name."','".$phone."','".$id_type."','".$id_num."','".$userid."','".$openid."')";
- }
- //writeLog($sql_search);
- $rs = $pdo->query($sql);
- $rowset = $rs->fetchAll(PDO::FETCH_ASSOC);
- if($rowset){
-
- echo json_encode(array('code'=>'0','info'=>'0'));
- }else{
- echo json_encode(array('code'=>'0','info'=>'0'));
- }
|