![]() |
Autoload Database not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Autoload Database not working (/showthread.php?tid=60861) |
Autoload Database not working - El Forum - 07-14-2014 [eluser]AntonioAntar[/eluser] Hello friends. I have been trying to connect my database (phpMyAdmin) to the website I'm working on I'm trying to set up a login form. I'm having a problem retrieving data from the database (I'm trying to retrieve login credientals from a table). So this is what I have as my set up for the database from my database.php file Code: $active_group = 'default'; The database name i want to retrieve the data from is called test and my localhost is localhost:1337 Next step would be autoloading the database and this is where my problems start to happen. This is what I have as default in my autoload.php file Code: $autoload['libraries'] = array(); Code: $autoload['libraries'] = array('database'); When I remove 'database' from array i load the localhost and everything is working again Now I tried to load the database in my model like this Code: $this->load->database(); Friends, any help would be greatly appreciated Thank you very much AntonioAntar Autoload Database not working - El Forum - 07-14-2014 [eluser]treenef[/eluser] I'm using mamp and my port number is 8888. But in my database config file I leave it as just 'localhost' In my default site url I specify the port there eg $config['base_url'] = 'http://localhost:8888/mysite/'; Autoload Database not working - El Forum - 07-14-2014 [eluser]AntonioAntar[/eluser] This is also what I have for my config Code: $config['base_url'] = 'http://localhost:1337/mysite/'; What I have is a login portal. I want the users to input their email and password, and then I want the controller to check the database to see if the email and password exist, and if they do, the website will direct them to the 'members' page if the email and password do not match, i want the message displayed 'Incorrect username/password' I have sample emails and passwords stored in database, but when I input the email and password in the database, the login portal always brings me back to the login page This is my code For my controller I have Code: public function login_validation(){ The part that isn't working in this code seems to be the validate_credentials part. I input the correct email and password, but the browser does not take me to the 'members page' This is what I have for my model Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); The table I'm trying to pull the email and password from is called users Autoload Database not working - El Forum - 07-14-2014 [eluser]treenef[/eluser] So is this a load database issue or an issue with your code? Eliminate one by doing a simple select statement. If you can do a simple select statement this has nothing to do with autoloading the database. If it is your code that is an issue I can't help. You'll have to debug it. Just looking at it I would pass the email and password as parameters to your model eg. load_model->checklogin($email,$password) That should fix it. |