[eluser]Slowcheetah[/eluser]
Okay, i will be more specific.
p.s. i removed all unnecessary code.
Check credentials function in the myaccount controller
Code:
/**
* Check credentials for a page
*
* @access private
* @version 0.1
* @param $username, $password, $error_page- string
* @return Bool - TRUE or redirect to error page
*/
function _check_credentials($username, $password, $error_page) {
// check variables
if ($username <> "" && $password <> "") {
// check if account is signed-in
if ($this->accounts_model->check_credentials($username, $password) == FALSE) {
redirect($error_page);
exit;
} else {
return TRUE;
}
} else {
redirect($error_page);
exit;
}
}
check credidentials function in account model
Code:
/**
* function check_credidentials()
*
* Checks if account credentials are valid
* @version 0.1
* @param $username, $password - string
* @return Bool - TRUE or FALSE
*/
function check_credentials($username, $password) {
$this->db->where('username', $username);
$this->db->where('password', $password);
$this->db->where('verified', 1);
$query = $this->db->get('accounts', 1);
if ($query->num_rows() == 1) {
return TRUE;
} else {
return FALSE;
}
}
Function where i check the credentials in the myaccount controller
Code:
/**
* function details()
*
* retrieve account details
* @access public
* @version 0.1
*/
function details() {
// Set if page is secured
$secured_page = TRUE;
// Set permitted role
$permitted_role = 100; // 100 = user
// check credentials
if ($secured_page == TRUE) {
// place variables
$username = $this->session->userdata('username');
$password = $this->session->userdata('password');
// check credentials in database
if ($this->_check_credentials($username, $password, $error_page) == TRUE) {
echo "do this";
} else {
echo "do that";
}
}
}