If there's someone logged in, this code checks the sessions and I can successfully view the page, but now I'd like to check if the user is admin. I've tried checking for this in the model and I keep getting a few errors. One of them is "Fatal error: Call to undefined function where() in C:\xampp\htdocs\ecwm604\application\models\usermod el.php on line 54" - public function index()
-
{
-
$this->load->library('authlib');
-
$loggedin = $this->authlib->is_loggedin();
-
///$admin = $this->auth->admin();
-
-
if ($loggedin === false) {
-
$this->load->helper('url');
-
redirect('/auth/login');
-
}
-
if ($this->auth->admin() === false) {
-
$message ['msg'] = "You are not an admin!";
-
$this->load->view('homeview', $message);
-
}
-
else
-
{
-
$this->load->view('add_view');
-
}
-
}
-
The line $this->admin($username,$password); passes to admin() below - --Controller Auth
-
-
public function authenticate()
-
{
-
$username = $this->input->post('uname');
-
$password = $this->input->post('pword');
-
$user = $this->authlib->login($username,$password);
-
>> $this->admin($username,$password); <<passes to admin()below
-
if ($user !== false) {
-
$this->load->view('homeview',array('name' => $user['name']));
-
-
}
-
else {
-
$data['errmsg'] = 'Unable to login - please try again';
-
$this->load->view('login_view',$data);
-
}
-
}
-
-
public function admin($username,$password){
-
//$this->load-model('usermodel');
-
$admin = $this->authlib->adminlib($username,$password);
-
if ($admin == false){
-
return false;
-
//if ($res->num_rows() != 1){
-
//return false;
-
}
-
}
- --Library Authlib
-
-
public function adminlib($user,$pwd)
-
{
-
return $this->ci->usermodel->chkadmn($user,$pwd);
-
}
-
Error is taking place on line 5 below: - --Model Usermodel
-
-
function chkadmn($username,$password)
-
{
-
<<This is where the error is taking place>>$this->db-where(array('username' => $username,'password' => sha1($password)));
-
$res = $this->db->get('users',array('type'));
-
if ($res->num_rows() != 1) {
-
return false;
-
}
-
}
3 6360 zmbd 5,501
Expert Mod 4TB
ethio:
Merely posting the code and giving a generic, paraphrased, error message and the "this doesn't work" is not enough to help you. Bytes is not a code writing nor homework service. Please read the FAQ and posting guidlines. I hate to just outright delete the post as you've taken the time to include your code.
However:
We must insist that you take the time to do the basic trouble shooting on your own system first in that we do not have the same PC, programs, nor access to your data.
As for errors, you must provide the EXACT title, error number, and error description along with at what point in your code the error occurs - without this basic information, it's is difficult at best to offer any help.
So, without some basic effort and information on your part, even if someone manages to offer you some guidance, your thread may be subject to deletion.
I have taken the time to do basic trouble shooting on my own system. In fact, I've been trying to fix this since yesterday night. But I have added the exact error message and it happens in the usermodel $this->db->where(...
I've added some comments to your post (taken from your code) which should help explain the problem better (it's easy to miss in all the lines of code).
I don't use CodeIgniter, but is there not a better method to check for admin, e.g. roles?
As for your error, is $this->db-where a typo or did you miss the > character, i.e. it should be $this->db->where ?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gaurav |
last post by:
Hi,
is there a way to know which user last logged in the shared Access
database.
My requirement is that I must be able to track the users that log in
the database and incase its not working...
|
by: Joe Saliba |
last post by:
hi, hope somebody could help me with this, have some users created on an
sql 2000, and am trying to know which user opened the adp , so everytime
i put msgobx currentuser it gives me admin, though...
|
by: Alan Silver |
last post by:
Hello,
I have some pages that are protected by forms authentication, and am
adding code to the global.asax so that if someone tries to load (say)
/order83.aspx, if they are logged in, it will...
|
by: Jeff |
last post by:
I have a system on a network and want to determine if anyone is currently
connected to the back-end files.
An interesting twist is that I have noticed that some users can be connected
(have the...
|
by: pagates |
last post by:
Hi All,
This must be a simple question, but I just can't figure it out. I want to
know if the user is logged in programmatically. I tried to use the
LoginStatus control, but of course that...
|
by: Dan Holmes |
last post by:
I admit this not being C# specific but i don't know where else to start.
My application needs an "administrator" user id. This would function
just like the "administrator" user id in windows. ...
|
by: surfivor |
last post by:
I am doing some preliminary research as we are slated to do a project
with wordpress. I looked at the wordpress code and realized why I like
MVC so much (Rails) because the code mixed in with the...
|
by: TheServant |
last post by:
Can anyone tell me why flashdata is not immediately available? Is it only available once the page has been resent? I am using form validation for form fields and flashdata for error messages. If...
|
by: dlite922 |
last post by:
Hey guys,
I can't find a good snippet to check whether an php error has occurred (maybe warning and notices too).
I'm doing this for codeIgniter. I'm trying to prevent my template/view from...
|
by: vivekgs2007 |
last post by:
hi to all,
I am using the php from last 1 year…this is my first framework i am using i downloaded CodeIgniter and made the configaration as listed above..i am also using wamp server..
I am getting...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |