check if a value already exists in database |
How to check if a value already exists in database using built in form validation methods ?
Thanks in advance
See the documentation for making your own callback methods:
https://www.codeigniter.com/userguide3/l...on-methods It is within one of these callback methods that you would simply query your database for an existing value.
There is also a built-in validation rule for that: is_unique.
https://www.codeigniter.com/user_guide/l...-reference Note that under CI version 2, if you chained validation rules, you could not put spaces between them. PHP Code: // works
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
(01-02-2016, 01:18 AM)RobertSF Wrote: There is also a built-in validation rule for that: is_unique. This is the easier way to do it, but if you want to have a customized error message then you need to use a callback, or do something creative with str_replace.
Thanks for help.
I need the reverse of is_unique ie, the rule should return true if an entry exists in the database.
Then you need to add a callback function:
PHP Code: <?php
I know it can be done with callbacks.
Just looking for in-built validation methods. Thanks (01-01-2016, 09:30 PM)shanavas_m Wrote: yeah, i am late for a reply, but i have the simplest way to check if a value already exists, just extend form validation class by MY_Form_validation like this: PHP Code: <?php now, create form_validation_lang.php file in your language directory and: PHP Code: <?php that's all, now u can use in this way ![]() PHP Code: $rules = array( |
Welcome Guest, Not a member yet? Register Sign In |