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.
 
 
 
 

44 lines
1.2 KiB

  1. <?php
  2. /*
  3. Author:ZSQ
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. header("Access-Control-Allow-Origin:*");
  8. $agoPwd=isset($_POST['agoPwd'])?$_POST['agoPwd']:'';
  9. $nowPwd=isset($_POST['nowPwd'])?$_POST['nowPwd']:'';
  10. if($agoPwd==''||$nowPwd==''){
  11. echo json_encode(array("errcode"=>4,"errinfo"=>"密码为空"));
  12. exit;
  13. }else{
  14. $md_agoPwd = md5($agoPwd);
  15. $md_nowPwd = md5($nowPwd);
  16. }
  17. $user_id=getUserId();
  18. if ($user_id ===false){
  19. echo json_encode(array("errcode"=>1,"errinfo"=>"用户未登录"));
  20. exit;
  21. }
  22. $md5_ago_pwd = md5($agoPwd);
  23. $md5_new_pwd = md5($nowPwd);
  24. $pdo=conn();
  25. $sql = " SELECT ID FROM base_user WHERE ID={$user_id} AND USER_PASSWORD='{$md5_ago_pwd}' ";
  26. writeLog("check old password:".$sql);
  27. $result=$pdo->query($sql);
  28. if( $result == false ) { echo json_encode(array("errcode"=>1,"errinfo"=>"旧密码输入有误"));exit; }
  29. $rowset=$result->fetchAll();
  30. if( $rowset == false ) { echo json_encode(array("errcode"=>1,"errinfo"=>"旧密码输入有误"));exit; }
  31. $result->closeCursor();
  32. $sql_update = " UPDATE base_user SET USER_PASSWORD='{$md5_new_pwd}' WHERE ID={$user_id} ";
  33. $pdo->exec($sql_update);
  34. echo json_encode(array("errcode"=>0,"errinfo"=>"密码修改成功"));
  35. exit;