So I just started to use Codeigniter, and can't understand why what I'm doing isn't working.
My controller is like that:
class Tienda extends CI_Controller {
public function index(){
$this->load->view('inicio_view');
}
public function entrar(){
$nom= $this->input->post('nom');
$pass= $this->input->post('pass');
if($nom && $pass){
$data['nom']=$nom;
$data['pass']=$pass;
$this->load->model('Login_model');
$user=$this->Login_model->get_usuario($nom, $pass);
var_dump($user);
if ($user[0]['id']=='1'){
$this->load->view('Catalogo_view');
}
}
}
}
My initial view
<html>
<head>
<meta charset="utf-8">
<title>TIENDA</title>
</head>
<body>
<h1>TIENDA</h1>
<div class="form">
<form action="<?php echo base_url('Tienda/entrar');?>" method="post">
Usuario: <input type="text" name="nom"/>
<br/>
Contraseña: <input type="text" name="pass"/>
<br/>
<input type="submit" value="Enviar" />
</form>
</div>
</body>
</html>
And in the login_model I'm just calling to get the user and the pass
class Login_model extends CI_Model {
public function get_usuario($nom,$pass){
//$query = $this->db->get_where('usuarios',array('nom'=>$nom,'pass'=>$pass));
$query = $this->db-> query('SELECT id FROM usuarios where nom = "'.$nom.'" and pass = "'.$pass.'";');
return $query->result_array();
}
}
I don't know how many hours I've been searching and changing things, but it still doesn't work. Also, I checked almost every post of people who had that problem, but still can't make it work.
My catalog_view is just a h1 that says it works, because I just wanted to see if I can make it work but... I just don't know what it's happening. If there's any help here, it would be appreciated!