I’m completely baffled, i have created a multilevel user login system but upon login it just shows a blank page and the function in the url /Login/auth and no errors.
I’ve tried a million different things to see where the script is stopping and i believe its the Loginmodel.
I’m new to OOP php so be gentle …
I’m completely baffled as i should be getting an error with the password_verify (which i know is incorrect but thats another battle for once i’ve fixed this one).
Please can someone advise where i might be going wrong:-
INFO - 2020-01-04 10:05:41 --> Config Class Initialized
INFO - 2020-01-04 10:05:41 --> Hooks Class Initialized
DEBUG - 2020-01-04 10:05:41 --> UTF-8 Support Enabled
INFO - 2020-01-04 10:05:41 --> Utf8 Class Initialized
INFO - 2020-01-04 10:05:41 --> URI Class Initialized
INFO - 2020-01-04 10:05:41 --> Router Class Initialized
INFO - 2020-01-04 10:05:41 --> Output Class Initialized
INFO - 2020-01-04 10:05:41 --> Security Class Initialized
DEBUG - 2020-01-04 10:05:41 --> Global POST, GET and COOKIE data sanitized
INFO - 2020-01-04 10:05:41 --> Input Class Initialized
INFO - 2020-01-04 10:05:41 --> Language Class Initialized
INFO - 2020-01-04 10:05:41 --> Loader Class Initialized
INFO - 2020-01-04 10:05:41 --> Helper loaded: url_helper
INFO - 2020-01-04 10:05:41 --> Database Driver Class Initialized
INFO - 2020-01-04 10:05:41 --> Session: Class initialized using 'files' driver.
INFO - 2020-01-04 10:05:41 --> Controller Class Initialized
INFO - 2020-01-04 10:05:41 --> Model "Loginmodel" initialized
INFO - 2020-01-04 10:05:41 --> Helper loaded: form_helper
INFO - 2020-01-04 10:05:41 --> Form Validation Class Initialized
INFO - 2020-01-04 10:05:41 --> Final output sent to browser
DEBUG - 2020-01-04 10:05:41 --> Total execution time: 0.0304
Also where would you suggest the Force Error echo goes? Model or Controller?
I’m guessing and because of the above would try and find which view is being called by echoing the following before calling the view.
// Modify to suit requirements
echo '<pre>';// add line feeds to array elements
echo __method__;
echo __line__;
print_r($this->variable_To_examine);
die: // halt execution and show results in browser
// Script to call view
appears to be specifying a “where” condition for the password matching the password that the user types. Unless you’re storing plain-text passwords, or the next line somehow alters things (and I think it looks like a call to password_verify that does nothing with the result), I can’t see how this would retrieve a user.
Thanks John, i placed it in the model as it had no effect in the controller and it fired an error of undefined property and then as from the variable in print_r it echoed the data that was supplied from the login form. Being new to OOP i’m not sure where to go from here.
Currently i’m learning Codeigniter. The passwords are currently hashed using password_hash. Being new to this framework & OOP i’m trying to figure out how to compare the hash in the db with the password that the user has submitted.
So i see 2 ways of doing verifying the password vs the hash;
option 1: i hash the password from the form in the controller before its checked against the validate function which calls the model and checks the password hash against the db or…
option 2: inside the model i check the hash against the database and then return the data back to the controller to continue…
Model for reference:- (This is the best option i’ve come up with so far)
I need password_verify to compare the users password in a hashed format against the users hashed password thats stored on the database.
Once the password_verify function has compared the 2 hashes and agreed they match for the script to continue accordingly.
@oli_d111 You need to retrieve the user by username then pass the retrieved hashed password to the password_verify function.
Trying to use the password in a where statement is fundamentally wrong. The hashed password stored in the database contains a builtin salt value which means that even using the same plaintext password you will never be able to generate the same hash. password_verify takes care of that for you.
And I know it’s off-topic but what is motivating you to learn CI? Which version? You might find that using a more popular framework might be more effective.
To be fair, i’m just trying to figure out a way of getting the password_verify function to work. Whether it be initially called in the controller or model. Would it be helpful if i posted the remainder of the controller so that you can see?
Thanks for the code, unfortunately i got the same error + another:-
password_verify() expects parameter 1 to be string, object given
Call to a member function num_rows() on bool
Hi Ahundaiak
Appreciate your advice & i completely get it ultimately its what i’m aiming for but unfortunately being new to OOP i’m not sure how exactly to accomplish this.
As for learning CI (V3.0), it looked like an easier approach to learning MVC after battling and failing with installing Composer for Laravel i ended up just trying CI as it was uber quick to get up and running. Ultimatley i know that Laravel is better framework but for now i’m just learning. Besides frameworks aside, would i not have the same issue in Laravel as i do in CI for this pw verify issue?
Are you aware of CodeIgniter’s latest version? It started a couple of years ago and the new release is imminent. I get the impression and hopefully that this version is written “standing on the shoulder’s of giants”. The new version appears to use only the best features from existing PHP Frameworks. I have used the GitHub version and it is a vast improvement over the first version first Released February 28, 2006!
Yes indeed I am aware that there is a yet to be released new version coming out. From my admittedly cursory reading, I don’t think CI4 will really share much with CI3. Hence my skepticism that CI is really the best platform for learning OOP. But of course this discussion is off-topic.
It just seems that it should be easy to query for the user’s password for a given email. And then use password_verify. But I am not seeing any evidence of that.
I couldn’t agree more. I think there is probably a simple way i’m just not seeing it being new to OOP & MVC. Looking forward to seeing what CI4 holds though. Looking at the documentation it definitely looks positive.
If i could get ruddy composer installed i would start learning Laravel