Welcome Guest, Not a member yet? Register   Sign In
help with login/session
#1

[eluser]KrizzAngel[/eluser]
before i explain the problem/error that ive been getting, here are the cont/view/model that i have:
my login block in my view page.
Quote:<?php
echo form_open('mont/validate_credentials');
echo "Username:".form_input('username');
echo "Password:".form_password('Password');
echo form_submit('submit', 'Login');
echo form_close();
?>

my controller.
Quote:<?php
class Mont extends Controller
{
function mont()
{
parent::controller();
}
function index()
{
$this->load->view('home');
}

function upanel()
{
$data['list']=$this->db->get('tbltopic');
$this->load->view('userpanel', $data);
}
function validate_credentials()
{
$this->load->model('users');
$query = $this->users->validate();

if($query) // if the user's credentials validated...
{
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata("$data");
$this->upanel();
}
else // incorrect username or password
{

$this->index();
}
}

}

?>


my model.
Quote:<?php
class Users extends Model {

function validate()
{
$this->db->where('username', $this->input->post('username'));
$this->db->where('Password', $this->input->post('Password'));
$query = $this->db->get('tblstudent');

if($query->num_rows == 1)
{
return true;
}

}
}
?>

ok, so thats the important files to post i think.. so whenever i think to login ( ofc with correct UN and PWD that is in my database. i always getting this error. I have some basic-intermediate knowledge when it comes to php but a friend told me to use this CI bcoz im kinda short on time to finish my system for school XD. and oh its my first time to use framework such as this CI. hope you can help guys..
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Mont::$session

Filename: controllers/mont.php

Line Number: 29

Fatal error: Call to a member function set_userdata() on a non-object in C:\wamp\www\Montissori\system\application\controllers\mont.php on line 29
#2

[eluser]faxtion[/eluser]
Make sure you initialize sessions either in the controller or by auto load

Code:
$this->load->library('session');
#3

[eluser]KrizzAngel[/eluser]
tnx. now i can continue my progress <3




Theme © iAndrew 2016 - Forum software by © MyBB