I follow a tutorial from youtube Tutorial codeigniter - Insert but, Im getting this error inside my controller file for my browser when im using the encryption library from codeigniter 2.
Error code when using encryption.
$paramUsu['clave'] = $this->encrypt->sha1($this->input->post('txtClave'));
But when im just passing it without the encryption it working just fine.
$paramUsu['clave'] = $this->input->post('txtClave');
Im getting this error at my browser:
Fatal error: Call to undefined method CI_Encrypt::sha1() in C:\xampp\htdocs\TRAINING\tutorialCI\application\controllers\cpersona.php on line 31
A PHP Error was encountered Severity: Error
Message: Call to undefined method CI_Encrypt::sha1()
Filename: controllers/cpersona.php
Line Number: 31
Backtrace:
Here is the code for my controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Cpersona extends CI_Controller {
function __construct()
{
parent::__construct();
//call model
$this->load->model('mpersona');
$this->load->model('musuario');
//call encryption library for password at 'clave' textfield
$this->load->library('encrypt');
}
public function index(){
$this->load->view('persona/vpersona');
}
public function guardar(){
//persona
$param['dni'] = $this->input->post('txtDNI');
$param['nombre'] = $this->input->post('txtNombre');
$param['appaterno'] = $this->input->post('txtApPaterno');
$param['apmaterno'] = $this->input->post('txtApMaterno');
$param['email'] = $this->input->post('txtEmail');
$param['fecnac'] = $this->input->post('datFecNac');
//usuario
$paramUsu['nomUsuario'] = $this->input->post('txtUsuario');
//$paramUsu['clave'] = $this->input->post('txtClave');
$paramUsu['clave'] = $this->encrypt->sha1($this->input->post('txtClave'));
//call function name in model
//call function variable '$param'
//$this->mpersona->guardar($param);
$lastId = $this->mpersona->guardar($param);
//check if $lastId is filled in persona table
if ($lastId > 0){
$paramUsu['idPersona'] = $lastId;
//$paramUsu value will be go also in usuario model
$this->musuario->guardarUsuario($paramUsu);
}
}
}
its done
I just do it like this.
$param['clave'] = sha1($this->input->post('txtClave'));
You can use sha1 ()
as shown below:
$param['clave'] = sha1($this->input->post('txtClave'));