- Code: Select all
<?php
class LoginModel extends CI_Model
{
public function login($user, $pass)
{
$this->db->where('username', $user);
$this->db->where('password', md5($pass));
$query = $this->db->get('korisnici');
if ($query->num_rows() == 1)
{
$obj = array();
foreach ($query->result() as $row) {
$obj[] = $row;
return $obj;
$this->getData($obj);
}
return TRUE;
}
else return FALSE;
}
public function getData($obj)
{
$this->db->where('id', $obj['id']);
$upit = $this->db->get('korisnici');
return $upit->result();
}
}
?>
My view:
- Code: Select all
<div id="pocetak">
<?php
foreach ($records as $rec){
echo "<p id='bbb'><b >" .$rec->username. "</b>:dobrodosli</p>";
}
?>
My Controller:
- Code: Select all
public function checkAdmin()
{
$this->load->model('LoginModel');
$data['records'] = $this->LoginModel->getData($obj);
$this->load->view('pocetna_admin', $data);
}
When I start project, I get this:
- Code: Select all
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: obj
Filename: controllers/LoginController.php
Line Number: 50
I need help!!!

