MVC Codeigniter

Asked

Viewed 50 times

0

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

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

Home 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('/'));
    }

At last my Model:

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

Thank you very much!

  • As suggested by Guilherme Nascimento, I removed the simple quotes of the variable, but it is not working yet.

1 answer

1


This is wrong:

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

Single quotes (apostrophes) do not understand PHP variables, just pass directly:

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

For presently what yours model() this receiving is a string containing this "$h" and not the value of GET.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.