public function changePassword() { $userid = $this->input->post("UserID"); $oldpwd = $this->input->post("OldPwd"); $newpwd = $this->input->post("NewPwd"); $this->load->model("user"); try { $user = $this->user->get_by_userid($userid); if ($user != null && $user->UserPW == encpassword($oldpwd)) { $this->user->change_password($userid, encpassword($newpwd)); echo json_capsule(array('Response' => 'Success')); } else { echo json_capsule(array('Response' => 'Fail', 'RtMsg' => 'The user ID or password is not correct.')); } } catch (Exception $e) { echo json_capsule(array('Response' => 'Fail', 'RtMsg' => 'Failed to change password', 'Error' => $e->getMessage())); } }
function modify_member() { global $data; global $TABLE; // Set validation rules $this->form_validation->set_rules('centercode', 'Center Code', 'required'); $this->form_validation->set_rules('userid', 'User ID', 'required'); $this->form_validation->set_rules('userpwd', 'Password', 'required'); // If validation is failed if ($this->form_validation->run() == FALSE) { $this->load->admin_view("member_register", $data); } else { try { $seq = $this->post("seq", ""); $seq = $this->dbop->update($TABLE['user'], array("CenterCode" => $this->post("centercode", ""), "UserNm" => $this->post("name", ""), "UserID" => $this->post("userid", ""), "UserPW" => encpassword($this->post("userpwd", "")), "BirthDt" => $this->post("birthdt", ""), "Sex" => $this->post("sex", "1"), "Phone" => $this->post("phone", ""), "Email" => $this->post("email", ""), "Height" => $this->post("height", "")), array("Seq" => $seq)); gopage("admin/cmember/lists?page=" . $this->post("page", 0)); } catch (Exception $e) { } } }