How to compare data from a textfield to data in a mysql db using CodeIgniter? |
[eluser]Zombie1[/eluser]
Hello all, I started using CodeIgniter yesterday afternoon so I'm a newbie at this. I've designed a controller that checks if the username and password are equal to the data inside the db. The validation works fine if the user doesn't enter anything into them, (required), but for some reason the controller doesn't enter the functions that check the value of the textfield to the value stored inside the db. I'm don't think I'm calling the functions inside the controller correctly. Here's the code for the controller: Code: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Here's then code for the model: Code: class Log_in_db extends CI_Model { I've been trying to find a solution to this for the last couple of hours. Any help would be appreciated.
[eluser]treenef[/eluser]
You are using it incorrectly. You can either call the model function in the success of the form validation function, or create your own function in the form validation bit.
[eluser]Zombie1[/eluser]
Thanks it worked. I split half the code up calling one function inside the success section and then simply calling the model inside that function.
[eluser]treenef[/eluser]
I know this is solved, but take a look at creating your own callbacks http://ellislab.com/codeigniter/user-gui...#callbacks This allows you more control and allows you to echo specific error messages. You might want to take a look.
[eluser]CroNiX[/eluser]
I prefer to extend the form_validation library with additional custom rules. That way they can be reused in many controllers without having to copy the callback function to each one that uses that rule. |
Welcome Guest, Not a member yet? Register Sign In |