[eluser]Alexander Radsby[/eluser]
&I;have this problem, if a person isn't logged in he will redirected to a login page.
When you enter the username & password and click submit, you'll get redirected to a checklogin funktion.
The thing is that I want to make an instance of the user model, set the instance variabels and then just check if they exist by echoing them. But when I do this I get nothing. Nothing happens.
Can someone explain this for me? The whole thing is really simple actually, I need this to work so I can continue with CI
Check the code for the
function checklogin and
the user model. I commented out the code so you can focus on the code in the function checklogin and in the user model.
Thanks!
Login Controller
Code:
<?php
class Login extends Controller {
/*
function Login()
{
parent::Controller();
$this->load->library('session');
$this->load->library('validation');
$this->load->helper(array('form', 'url'));
}
function index()
{
if(!$this-;session->userdata('authenticated')) {
$this->load->view('admin/login_view');
}
else
{
redirect('admin/dashboard');
}
}
*/
function checklogin()
{
$name = $this->input->post('username');
$password = md5($this->input->post('password'));
$this->load->model('user_model');
$this->user_model->set_name($name);
$this->user_model->set_password($password);
echo $this->user_model->get_name();
echo $this->user_model->get_password();
}
}
User Model
Code:
<?php
class User_model extends Model {
var $name = '';
var $password = '';
function User_model()
{
parent::Model();
}
function set_name($name)
{
$this->name = $name;
}
function set_password($password)
{
$this->password = $password;
}
function get_name()
{
return $this->name;
]
function get_password()
{
return $this->password;
}
}
?>
*edit took away the wrongly formatted () in the model