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.
 
 
 
 
 

52 lines
1.6 KiB

  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. if (ALLOW_ORIGIN)
  9. header("Access-Control-Allow-Origin:*");
  10. date_default_timezone_set('PRC');
  11. $userid =1;//$_COOKIE['user_id'];
  12. $openid = 1;//$_COOKIE['open_id'];
  13. $id = isset($_POST['id'])?$_POST['id']:'0';
  14. $name = isset($_POST['name'])?$_POST['name']:'test';
  15. $phone = isset($_POST['phone'])?$_POST['phone']:'0';
  16. $id_type = isset($_POST['id_type'])?$_POST['id_type']:'0';
  17. $id_num = isset($_POST['id_num'])?$_POST['id_num']:'0';
  18. $reg = "/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/";
  19. if($id_num){
  20. if(!preg_match($reg,$id_num) && $id_type == 150){
  21. echo json_encode(array('code'=>'1','info'=>'身份证号码有误'));
  22. die;
  23. }
  24. if(!$name||!$id_type||!$id_num){
  25. echo json_encode(array('code'=>'1','info'=>'请填写完整信息'));
  26. die;
  27. }
  28. $sql = "update wechat_customer set name = '".$name."',id_type = '".$id_type."', id_num = '".$id_num."' where id =".$_POST['id'];
  29. $rs_u = $pdo->exec($sql);
  30. if(isset($rs_u) && !$rs_u){
  31. echo json_encode(array('code'=>'0','info'=>'信息修改'));
  32. die;
  33. }else{
  34. echo json_encode(array('code'=>'0','info'=>'信息已修改'));
  35. die;
  36. }
  37. }else{
  38. $sql = "select id,name,id_type,id_num from wechat_customer where id ='".$id."'";
  39. $rs = $pdo->query($sql);
  40. $rowset = $rs->fetchAll(PDO::FETCH_ASSOC);
  41. if(isset($rowset[0])){
  42. echo json_encode(array('code'=>'0','info'=>'0','list'=>$rowset[0]));
  43. }else{
  44. echo json_encode(array('code'=>'1','info'=>'未找到此条信息'));
  45. }
  46. }