Good afternoon everyone.
I do not know if I am doing well or if it is necessary to do so.
I am working on a development with PHP and Codeigniter and I have two files one in the Controller folder and another in Model ; what I try to do is that in the generate_link_temporal method of Controller generate a token, depending on the values that it asks for, then go to up_token_login located in Model with the parameters and this function I update that data in the database, until then everything is fine, it works correctly; but now I want to continue in generate_link_temporal of Controller and bring me a result like the update was generated correctly.
<?php
public function generar_link_temporal($id_usuario, $documento){
//TRAE EL ID DEL USUARIO Y EL DOCUMENTO DE IDENTIDAD, CONCATENA UN RANDOM DE 7 DIGITOS Y UNA FECHA
$cadena = $id_usuario.$documento.rand(1,9999999).date('Y-m-d');
//ENCRIPTA EL RESULTADO PARA MÁS SEGURIDAD Y FORMA EL TOKEN, QUE SE UTILIZARÁ PARA ENVIAR EL CORREO
$token = sha1($cadena);
$this->load->model('login_recovery');
$this->login_recovery->up_token_login($token,$id_usuario);
if(/* SI SE GENERÓ LA ACTUALIZACIÓN CORRECTAMENTE - ENTRE */){
$enlace = $_SERVER["SERVER_NAME"].'/PASS_CRASH/restablecer.php?idusuario='.sha1($documento).'&token='.$token;
echo $enlace;
exit;
}
else{
return FALSE;
}
}
?>
This is the generate_link_temporal of Controller
<?php
class login_recovery extends CI_Model{
function __construct()
{
parent::__construct();
$this->load->database();
}
public function up_token_login($token,$id_usuario,$val){
$now = date('Y-m-d H:i:s');
$data = array(
'T_TOKEN' => $token,
'T_CREADO' => $now
);
$this->db->where('T_ID_USUARIOS', $id_usuario);
$this->db->update('USUARIOS', $data);
}
}
?>
That's the Model
in the Controller part there is an if at the end and I do not know how to bring the $ connection-> query ($ result) successful, so that it enters that conditional and believes what is inside.
I thank anyone who can get me out of doubt.