You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

addcustomer.php 1.4 KiB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * wechat 2.0
  4. * Copyright (c) 2016 yixi wei http://zhizhuchuxing.com/
  5. * Date: 2016.7.12
  6. * Something is to pay QQ1062140302
  7. */
  8. header("Access-Control-Allow-Origin:*");
  9. date_default_timezone_set('PRC');
  10. $userid =$_COOKIE['user_id'];
  11. $openid = $_COOKIE['open_id'];
  12. $id = isset($_POST['id'])?$_POST['id']:'0';
  13. $name = isset($_POST['name'])?$_POST['name']:'0';
  14. $phone = isset($_POST['phone'])?$_POST['phone']:'0';
  15. $id_type = isset($_POST['id_type'])?$_POST['id_type']:'0';
  16. $id_num = isset($_POST['id_num'])?$_POST['id_num']:'0';
  17. $reg = "/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/";
  18. //if(!preg_match($reg,$id_num) && $id_type ==150){
  19. // echo json_encode(array('code'=>'1','info'=>'身份证号码有误'));
  20. // die;
  21. //}
  22. if(!$name||!$id_type){
  23. echo json_encode(array('code'=>'1','info'=>'请填写完整信息'));
  24. die;
  25. }
  26. if($id){
  27. $sql = "update wechat_customer set name = '".$name."',id_type = '".$id_type."', id_num = '".$id_num."' where id =".$_POST['id'];
  28. }else{
  29. $sql = "insert into wechat_customer(`name`,`phone`,`id_type`,`id_num`,`wechat_user_id`,`wechat_open_id`)"
  30. . " values('".$name."','".$phone."','".$id_type."','".$id_num."','".$userid."','".$openid."')";
  31. }
  32. //writeLog($sql_search);
  33. $rs = $pdo->query($sql);
  34. $rowset = $rs->fetchAll(PDO::FETCH_ASSOC);
  35. if($rowset){
  36. echo json_encode(array('code'=>'0','info'=>'0'));
  37. }else{
  38. echo json_encode(array('code'=>'0','info'=>'0'));
  39. }