![]() |
Creating basic Register (username/login/password) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Creating basic Register (username/login/password) (/showthread.php?tid=44148) |
Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]jvicab[/eluser] Another general suggestion: Don't add a __construct() function to your class if you don't need to put any code on it. It will prevent you for forgetting to call the parent constructor or misspelling it. Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]jvicab[/eluser] make sure the name of the file is usermodel.php and also you are assuming you create a constructor but you don't. Actually you have a diferent function, I mean, __User is not a class constructor, it is just another functuion inside it. Contructor name should be the same name of the class (function User), or better (php 5) function __construct(). It should be like: function __construct() // instead of __User { parent::__Controller(); $this->view_data['base_url'] = base_url(); $this->load->model('Usermodel'); } Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]jvicab[/eluser] I made a mistake, function __construct() { parent::__construct(); // instead of parent::__Controller(); $this->view_data[‘base_url’] = base_url(); $this->load->model(‘Usermodel’); } Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]toymachiner62[/eluser] Load your model in the register function instead of in the constructor. Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]terry101[/eluser] ok on my model i changed it a little (took off __construct() Code: class Usermodel extends CI_Model { I'm still getting the same error. any other ideas? Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]toymachiner62[/eluser] No. I'm talking about in your Controller, load the model in the register function rather than in the constructor function. Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]jvicab[/eluser] No, that is not right. You cannot name your consturctor like this. The constructor name is always __construct() regardless the name of the class, and the parent constructor should be called like parent::__construct(). Your problem is caused by one of two things: or you are not loading the model or you are but CI cannot link it based on the naming convention. Try to code your constructors (only if you need to put some code on it) the way I suggested (for controllers and models and any other class you intyent to extend): class Somename extends Parentclass { function __construct() { parent::__construct(); // your code here } } Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]terry101[/eluser] i'm confused, the register_user function is in 'usermodel'(i loaded that model) Code: $this->load->model('Usermodel'); Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]toymachiner62[/eluser] I said nothing about the register_user function. I said the "register" function. Creating basic Register (username/login/password) - El Forum - 08-05-2011 [eluser]jvicab[/eluser] ok, give me one minute, I will copy the code you posted earlier with my modifications, ok? |