Login3 |
[eluser]davy_yg[/eluser]
I create login with CI: controllers/admin/clogin.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); models/login_model.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); views/admin/login.php Code: <html> When I try to login it starts to bring me to this url: http://localhost/IndonusaCI/index.php?ad...in/process (home page) If type this url: http://localhost/IndonusaCI/index.php/ad...in/process This error appears: A PHP Error was encountered Severity: Notice Message: Undefined property: Clogin::$db Filename: core/Model.php Line Number: 51 Fatal error: Call to a member function get_where() on a non-object in C:\xampp\htdocs\IndonusaCI\application\models\login_model.php on line 18 line 18: $this->db->get_where('ids_user', $username); My questions are: 1. Why it shows error on line 18 ? 2. Why it bring me to the home page instead of the admin page after login ?
[eluser]DuyK-DCT[/eluser]
I guess that you've not read ci db active record document as well. First thing. You must load database after call "db" from ci super object. Like this (It will solve your first error) Code: $this->load->database(); And your problem in line 18 ? You call get_where as wrong with your intention. I guess you want to run this query: SELECT * FROM `user` WHERE `username` = 'input-username'; So when you call get_where() function, it included full query string. Like this Code: $this->load->database(); And your code above must be fix to: Code: $this->load->database(); // You can load database as automaticaly with autoload.php in /config folder
[eluser]davy_yg[/eluser]
I replace the code: Code: $this->db->get_where('ids_user', $username); with Code: $this->load->database(); // You can load database as automaticaly with autoload.php in /config folder and it still brings me to this url: http://localhost/IndonusaCI/index.php?verifylogin after I login.
[eluser]DuyK-DCT[/eluser]
Sorry my friend, this is my mistake (When comment for help you im so sleepy) Its must be: Code: $this->load->database(); // You can load database as automaticaly with autoload.php in /config folder |
Welcome Guest, Not a member yet? Register Sign In |