[eluser]opterons[/eluser]
Hello all,
I am a tad bit new to code igniter i understand allot of how ci works but i have got to the part in the manual where you can make your own library which i have but for some reason i can not load database() in my library im sure it is something stupid that i am missing but i thought i would give this forum a try.
Here is the controller code that i am using.
Controller, Login:
Code:
<?php
class Login extends Controller {
function index()
{
$this->load->library('accounts');
$this->load->helper('security');
$username = $this->input->post('username');
$password = $this->input->post('password');
$check = $this->accounts->check_login($username,$password);
if ($check == true) {echo 'hell ya';}
else {echo 'hell na';}
}
}
?>
the error is in the library on line 7 which is this line:
Code:
$this->load->database();
Here is the entire code that i have in that library
Library, Accounts:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Accounts {
function check_login($username,$password)
{
$this->load->database();
$query = $this->db->query('SELECT username, password FROM wz_users');
$login = false;
foreach ($query->result_array() as $row) {
if ($row['username'] == $username){
if ($row['password'] == $password) {
$login = true;
}
}
}
return ($login);
}
}
?>
When i try to run my root directory root/login i get this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Accounts::$load
Filename: libraries/Accounts.php
Line Number: 7
Now i am sure im doing something stupid being that i am new to ci but i am stumped maybe someone out there could possibly give me a hand.