get_session(); $model = $this->credential_model->get($session['credential_id']); $this->_data['email'] = $model->email; $this->_data['password'] = ''; $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email'); $this->form_validation->set_rules('password', 'Password', ''); if ($this->form_validation->run() === FALSE) { return $this->render('Member/Mes', $this->_data); } $email = $this->input->post('email'); $password = $this->input->post('password'); $payload = [ 'email' => $email, ]; if (strlen($password) > 1) { $payload['password'] = str_replace('$2y$', '$2b$', password_hash($password, PASSWORD_BCRYPT)); } $result = $this->credential_model->edit($payload, $session['credential_id']); if ($result) { $this->success('Saved'); return $this->redirect('/member/me', 'refresh'); } $this->_data['error'] = 'Error'; return $this->render('Member/Mes', $this->_data); } }