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.
 
 
 
 

46 lines
1.4 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. //require_once '../../Common/Mysql.php';
  4. $pdo= conn();
  5. $user_id=$_COOKIE['user_id'];
  6. //$user_id = getUserId();
  7. if (!$user_id) {
  8. echo json_encode(array("code" => 1, "info" => "用户未登录"));
  9. exit ;
  10. }
  11. //echo json_encode(array('code'=>0,'info'=>$user_id,'ss'=>$_SESSION['user_id']));die;
  12. $sql = "select `user_password`,`update_user_id` from base_user where id =".$user_id;
  13. $rs = $pdo->query($sql);
  14. $row = $rs-> fetchAll(PDO::FETCH_ASSOC);
  15. //var_dump($row);die;
  16. $password=$_POST['password'];
  17. $passwordc=$_POST['passwordc'];
  18. $password_old=$_POST['password_old'];
  19. if($password!='' && $password==$passwordc && $row[0]['update_user_id']==0){
  20. $sql_up = "update base_user set user_password = '".md5($_POST['password'])."',update_user_id = 1 where id= ".$user_id;
  21. }elseif($password!='' && $password==$passwordc && md5($password_old)==$row[0]['user_password']){
  22. $sql_up = "update base_user set user_password = '".md5($_POST['password'])."' where id =".$user_id;
  23. }
  24. // $code =1;
  25. // $info = 'fail';
  26. // $massge = '失败请稍后重试';
  27. // $list = "";
  28. if($rs_up = $pdo->query($sql_up)){
  29. $code =0;
  30. $info = 'success';
  31. $massge = '';
  32. $list = "";
  33. }else{
  34. $code =1;
  35. $info = $sql_up;
  36. $massge = '失败请稍后重试';
  37. $list = "";
  38. }
  39. $json['code'] = $code;
  40. $json['info'] = $info;
  41. $json['massge'] = $massge;
  42. $json['list'] = $list;
  43. echo json_encode($json);
  44. exit;