我按照youtube Tutorial codeigniter - Insert的教程,但是,
我使用codeigniter 2中的加密库时,我的浏览器控制器文件中出现此错误。
使用加密时的错误代码。
$paramUsu['clave'] = $this->encrypt->sha1($this->input->post('txtClave'));
但是当我只是在没有加密的情况下传递它时它工作正常。
$paramUsu['clave'] = $this->input->post('txtClave');
我在浏览器中收到此错误:
致命错误:在第31行的C:\ xampp \ htdocs \ TRAINING \ tutorialCI \ application \ controllers \ cpersona.php中调用未定义的方法CI_Encrypt :: sha1()
遇到PHP错误 严重性:错误
消息:调用未定义的方法CI_Encrypt :: sha1()
文件名:controllers / cpersona.php
行号:31
回溯:
以下是我的控制器的代码:
<?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);
}
}
}
答案 0 :(得分:0)
完成了
我就是这样做的。
$ param [&#39; clave&#39;] = sha1($ this-&gt; input-&gt; post(&#39; txtClave&#39;));
答案 1 :(得分:0)
您可以使用sha1 ()
,如下所示:
$param['clave'] = sha1($this->input->post('txtClave'));