passing custom error message between models and controllers and views. |
[eluser]chubbypama[/eluser]
I'm just new to codeigniter... I have a question about how to handle errors. I have a log in page that I've created, which includes the ability to create a new account. When someone tries to create a new account, the first thing i do is check if the user name already exists in my database. if it does, I'd like to be able to pass a user friendly error message to the view. (via the controller). Code: public function create_member() From what I've read, I can use either config files or session or global variables. It seems that global vars are a bad thing to do, based on my limited reading. Is this correct? The knee-jerk reaction I have to resolving this problem is to somehow create a global variable and pass that to the controller. Code: var $error_message; //this doesn't actually work. I still have to figure out why and then in the controller, do something like this: Code: $this->load->model('Membership_model'); I haven't gotten this prototype working yet because it's complaining about my get_error method in the model. It says that the variable $error_message hasn't been declared. But I would like some feedback / comments about how to handle 'expected' / 'potential' error messages and how to provide /pass the error message to the view. thanks.
[eluser]Cristian Gilè[/eluser]
You can use form validation and callback. Check the user guide: http://ellislab.com/codeigniter/user-gui...#callbacks
|
Welcome Guest, Not a member yet? Register Sign In |