Password change screen, form is ok, but the variable to fetch the information in the bd giving error, in the row () function!
Follow VIEW:
case 'alterar_senha':
$iduser= $this->uri->segment(3);
if($iduser=NULL):
set_msg('msgerro', 'Escolha um usuário para alterar', 'erro');
redirect('usuarios/gerenciar');
endif; ?>
<div class="large-12 columns">
<?php if (is_admin() || $iduser == $this->session->userdata('user_id')):
$query = $this->usuarios->get_byid($iduser)->row();
erros_validacao();
get_msg('msgok');
echo form_open(current_url(), array('class'=>'custom'));
echo form_fieldset('Alterar Senha');
echo '<div class="large-7 columns">';
echo form_label('Nome completo');
echo form_input(array('name'=>'nome', 'disabled'=>'disabled'), set_value('nome', $query->nome));
echo form_label('Email');
echo form_input(array('name'=>'email', 'disabled'=>'disabled'), set_value('email', $query->email));
echo '<div class="large-7 columns>"';
echo form_label('Login');
echo form_input(array('name'=>'login', 'disabled'=>'disabled'), set_value('login', $query->login));
echo form_label('Nova Senha');
echo form_password(array('name'=>'senha'), set_value('senha'), 'autofocus');
echo form_label('Repita a senha');
echo form_password(array('name'=>'senha2'), set_value('senha2'));
echo anchor('usuarios/gerenciar', 'Cancelar', array('class'=> 'button radius alert espaco'));
echo form_submit(array('name'=>'alterarsenha', 'class'=>'button radius '), 'Salvar dados');
echo form_hidden('idusuario', $iduser);
echo form_fieldset_close();
echo form_close();
else:
redirect('usuarios/gerenciar');
endif; ?>
</div>
<?php
break;
Follow CONTROLLER with function:
public function alterar_senha(){
esta_logado();
set_tema('titulo','Alteração de senha');
set_tema('conteudo',load_modulo('usuarios','alterar_senha'));
load_template();
}
Follow MODEL:
public function get_byid($id=NULL) {
if ($id != NULL):
$this->db->where('id', $id);
$this->db->limit(1);
return $this->db->get('usuarios');
else:
return FALSE;
endif;
}