php - Codeigniter user form errors not showing -


If the user types in incorrect user names in this code as the username or If the password is incorrect , the error should be visible and if the user enters the user name, which does not exist then the error does not match the username gives.

The form can not display errors in the database, the right way. I can log in properly, but login flash data may not correct errors.

How do I get errors in my form database to work correctly? The main codeigniter form validation is ok just not throwing my database errors

  Public Function Index () {$ this-> Load-> Library ('form_validation'); $ This- & gt; Form_validation- & gt; Set_rules ('username', 'username', 'required | trim'); $ This- & gt; Form_validation- & gt; Set_rels ('password', 'password', 'required'); If ($ this-> form_validation-> Run () == FALSE) {$ this-> Login (); } And {if ($ this-> Input-> Post ('username') & amp; it-> Input-> Post ('password')) // Database Receives user's information. $ User = $ this- & gt; User_login_model- & gt; Obtain ('username', $ this-> input- & gt; post ('username')); If ($ user) {// user login success ($ this-> user_login_model- & gt; check_password ($ this-> input- & gt; post ('password'), $ user ['password' ]) = = TRUE {$ this-> User- & gt; Login ($ user ['user_id']); Redirect ('admin / dashboard'); } And {$ this- & gt; Session-> Set_flashdata ('error', 'Username or password does not match any records!'); $ This- & gt; Login (); }}}}} Public Function Login () {$ this-> Document-> Settail ($ this->> Lang-> line ('heading_title')); $ Data ['text_login'] = $ this- & gt; Lang- & gt; Line ('text_login'); $ Data ['text_register'] = $ this- & gt; Lang- & gt; Line ('text_register'); $ Data ['entry_username'] = $ this- & gt; Lang- & gt; Line ('entry user name'); $ Data ['entry_password'] = $ this- & gt; Lang- & gt; Line ('entry_password'); $ Data ['action'] = site_url ('admin'); $ Data ['button_login'] = $ this- & gt; Lang- & gt; Line ('button_login'); $ $ - this- & gt; Load-> View ('normal / login', $ data) return; }   

Obtain user model

  / ** * Retrieve one user * * @The ultimate string where * @ absolute value * @param Get String User Identification Area * / Public Function ($ where, $ value = FALSE) {if (! $ Value) {$ value = $ where; $ Where = 'user_id'; } $ User = $ this- & gt; Db- & gt; Where ($ where, $ value) - & gt; Obtain ($ this- & gt; Table) - & gt; Row_array (); $ User return; }   

The FlashData will only be shown if the user is redirected to another page. On the failed login action, you only load a view on the user's screen. Try changing

to

('Admin / login'); // first change the name of the controller

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -