MVC CodeIgniter

0

I have a question regarding the passing of parameters between MVC.

I'm developing email confirmation on a project. After clicking on the link to confirm sent by email, the system picks up by GET, the encrypted password and "I want to change the 'active' field in the database."

Beginning of my Controller:

public function index()
{
    $this->load->model('confirma_model');

My View:

$h = $_GET['h'];

    if (!empty($h)) {               
        $this->confirma_model->confirma('$h');
    }else{
        redirect(base_url('/'));
    }

Finally my Model:

public function confirma($h){
    $this->db->where('md5(id)',$h);
    $dados['ativo'] = '1';
    return $this->db->update('usuario', $dados);
}

Thank you!

    
asked by anonymous 31.08.2018 / 21:20

1 answer

1

This is wrong:

$this->confirma_model->confirma('$h');

Simple quotes (apostrophes) do not understand PHP variables, just go directly:

$this->confirma_model->confirma($h);

Because what your model() is currently receiving is a string containing " $h " and not the value of GET.

    
31.08.2018 / 21:22