[eluser]richzilla[/eluser]
sorry for the slow reply, yes i thought thats how it worked but in my situation its refusing to. Ive pared my code back to the very basics to see if i can work out what im doing wrong. Basically i have :
my model:
Code:
<?php
class User_model extends Model {
function checklog($data) {
$res= $this->db->query("SELECT * FROM users WHERE userName = '".$data['userName']."' AND userPass ='". $data['userPass']."'");
if ($res)
{
return $res->result();
}
else
{
return 0;
}
}
}
my controller :
Code:
<?php
class Site extends Controller {
function index() {
$this->load->view('site_view');
}
function login() {
$this->form_validation->set_rules('username','User Name', 'required');
$this->form_validation->set_rules('password','Password','required');
$data = array (
'userName' => $this->input->post('username'),
'userPass' => $this->input->post('password')
);
if ($this->form_validation->run() == FALSE) {
$this->index();
}
else {
$res= $this->user_model->checklog($data);
if ($res != 0) {
$this->session->set_userdata(array('loggedIn' => TRUE, 'userId' => $res->id, 'userName' => $res->userName));
$this->secure();
}
else {
$err = array (
'error' => "The entered credentials were incorrect"
);
$this->load->view('site_view', $err);
}
}
}
function secure() {
$data = array (
'uName' => $this->session->userdata('userName')
);
$this->load->view('debug_view', $data);
}
}
EDIT: adding the view would help me a bit aswell...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>Debug</title>
</head>
<body>
<?php echo $uName; ?>
</body>
</html>
but i am consistently getting the error:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: views/debug_view.php
Line Number: 10
the SQL is ok, ive tried it directly and it works. I know its probably very simple, but i just cant see it. Any help would be appreciated.
Thanks