I am trying to pass an array through a function in a controller class and retrieve it from another function in a class inside model, but the values cannot be retrieved. please advise.
The code is as follows.
Controller class code
class home extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('url');
}
function index() {
$this->load->view('loginview');
}
function login() {
$parameters = array(
'$uname' => $this->input->post('uname'),
'$passwords' => $this->input->post('password')
);
$this->load->model('loginModel');
$validate = $this->loginModel->validateuser($parameters);
if(count($validate)== 1){
echo "Logged in";
}
else
{
//redirect('home/index');
echo "dasad";
}
}
}
Model class code
class loginModel extends CI_Model {
function __construct() {
parent::__construct();
}
public function validateuser($parameters) {
$uname = $parameters['uname'];
$pass = sha1($mem['pass']);
$query = $this->db->query("select * from user where username = '$uname' and password = '$pass'");
$result = $query->result_array();
return $result;
}
}
The variables $uname and $pass are the two values that need to get to query the database. please help