I use CodeIgniter form validation, and I spent a lot of time trying to fix this, no luck. I have this field:
<input type="text" name="user" id="user" length="20" placeholder="Username">
And I use this to check:
$this->form_validation->set_rules('user', 'Username', 'trim|required|min_length[3]|max_length[20]|alpha_dash|is_unique[users.user]');
My db has a users table and user is a field in it, so I don't know what I'm doing wrong, or what the problem is. The table is empty (but I also tried to have entries with it), and the " unique " icon was selected in phpmyadmin. I know that the db connection works fine, because if I delete this rule and enter other valid data and submit the form, the user will be added to the database.
If is_unique uses a different db configuration file, which I did not configure? I really do not know. This is frustrating, and I think I can just refuse to use the framework ...
Your help will be wonderful! Thanks.
php mysql validation forms codeigniter
justanelephant
source share