D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
alumni
/
application
/
controllers
/
user
/
Filename :
ChangePassword.php
back
Copy
<?php /** * Description of User * * @author Softpro India Pvt. Ltd. */ class ChangePassword extends CI_Controller { //put your code here public function __construct() { parent::__construct(); $this->load->model("user/UserManagement"); $this->load->model("admin/NotificationManagement"); } public function changePassword() { $userData = $this->session->userdata("userData"); $viewData["notificationList"] = $this->NotificationManagement->getNotificationsForUserDashboard($userData["userid"], $userData["user_role"])->result(); $this->load->view("user/changePassword", $viewData); } public function saveChangedPassword() { if ($this->sessionvalidator->validateSession("userData")) { $this->form_validation->set_rules("currentPassword", "current password", "required", array("required" => "Enter Current Password.")); $this->form_validation->set_rules("newPassword", "new password", "required", array("required" => "Enter New Password")); $this->form_validation->set_rules("confirmNewPassword", "confirm new password", "required|matches[newPassword]", array("required" => "Re-enter New Password")); $userid = $this->session->userdata("userData")["userid"]; $currentPassword = $this->input->post("currentPassword"); $newPassword = $this->input->post("newPassword"); $confirmNewPassword = $this->input->post("confirmNewPassword"); if ($this->form_validation->run() == false) { $this->changePassword(); } else if (sizeof($this->UserManagement->getUser($userid, md5($currentPassword))->result()) == 0) { $this->session->set_flashdata("errorMessage", "Enter Correct Current Password."); $this->changePassword(); } else { if (!(strtolower($currentPassword) == strtolower($newPassword))) { //when old and new password are different //print_r($this->UserManagement->getAdmin($admin_id, $currentPassword)->result()); $enc_new_password = md5($newPassword); $userData = array("userid" => $userid, "password" => $enc_new_password); if ($this->UserManagement->updateUser($userData)) { $this->session->set_flashdata("successMessage", "Password Changed Successfully."); $this->changePassword(); } else { $this->session->set_flashdata("errorMessage", "Failed To Change Password."); $this->changePassword(); } } else { // generate flash when new password and old password is same $this->session->set_flashdata("errorMessage", "New Password Can't Be Same As Old Password."); $this->changePassword(); } } } else { $this->load->view("Home#loginModal"); } } }