public function newpasswd() { $data = $_POST; if (empty($data['password']) || empty($data['password_two'])) { $msg['msg'] = '输入不能为空!'; $msg['result'] = "-4"; echo json_encode($msg); throw new Exception('exit'); } if ($data['password_two'] != $data['password']) { $msg['msg'] = '两次输入密码不一样,请重新输入!'; $msg['result'] = "-5"; echo json_encode($msg); throw new Exception('exit'); } $len = strlen($data['password']); if ($len < 6 || $len > 18) { $msg['msg'] = '请输入6-18个字符!'; $msg['result'] = "-6"; echo json_encode($msg); throw new Exception('exit'); } $code = htmlspecialchars($data['code']); $password = htmlspecialchars(trim($data['password'])); $info = Code::getCodeInfoByCode($code); if ($info) { $info = $info[0]; //更新密码 $updete_password_result = User::updatePasswordByEmail($password, $info['email']); if ($updete_password_result) { //删除code码 $delete_code_result = Code::deleteCodeByEmail($info['email']); $msg['msg'] = '修改密码成功!!'; $msg['result'] = '1'; LuS::set('email_save_url', url("login", "login::index")); LuS::set('email_save_msg', "修改密码成功!!点我到登录页面!"); $msg['url'] = url("login", "passwd::prompt"); echo json_encode($msg); throw new Exception('exit'); } } $msg['msg'] = '修改出错,或已使用!'; $msg['result'] = '-7'; echo json_encode($msg); throw new Exception('exit'); }