When a user tries to log in, then I am trying to check the status, if position is 0 Then redirect the administrator back. And then if the position 1 redirects to the dashboard.
I have tested it, even if sending me the dashboard, position 0
Var Dump array (1) {["status"] => string (1 ) "0"} *
What would be the best solution to ensure that it checks my logs on the situation
Model function
public function getStatus () {$ this- & gt; Db- & gt; Select ('position'); $ The-> gt; - gt; ($ This-> db-> dbprefix. 'User'); $ This- & gt; Db- & gt; Where ('username', $ this-> input- & gt; post ('username')); $ Query = $ this- & gt; Db- & gt; get receive (); Return $ query- & gt; Row_array (); }
Administrators
& lt ?? Php if (defined! ('BASEPATH')) Exit ('no direct script entry permissions'); Class Logan Admin_Controller {Public Function Index () {$ this- & gt; Form_validation- & gt; Set_rules ('username', 'username', 'required | callback_delidate') is extracted; $ This- & gt; Form_validation- & gt; Set_rels ('password', 'password', 'required'); If ($ ----- $ form_validation- & gt; Play ($ this) == incorrect) {$ this- & gt; Load-> View ('template / normal / login.tpl', $ this-> data); } And {$ this- & gt; Load-> Model ('admin / user / model_user'); Var_dump ($ this-> model_user-> getStatus ()); // array (1) {["status"] = & gt; String (1) "0"} Exit; If ($ this-> model_user-> GetStatus ()) {Redirect ('Admin / Dashboard'); } And {$ this- & gt; Session-> Set_flashdata ('Error', 'You have not been enabled by the webmaster. Please wait 24/48 hours if you need to contact the website master email.' 'Config_item (' config_email ')); Redirect ('admin'); }}}} Validate public function () {$ this-> Load-> Library ('user'); If ($ this-> User-> Login () == FALSE) {$ this-> Form_validation- & gt; Set_message ('validate', '& lt; i class = "fa fa-exclamation-triangle"> does not match our database records!'); return false; } And {return true; }}}}
The problem was resolved I had to remove some things from the controller, and Model
Model
Public function getStatus () {$ this- & gt; Db- & gt; Where ('username', $ this-> input- & gt; ('username')); $ Query = $ this- & gt; Db- & gt; Obtain ($ -> - db-> dbprefix. 'User'); $ Ret = $ query- & gt; Line (); Return $ rate- & gt; Event; }
Administrator
& lt ;? Php if (! Defined ('BASEPATH')) Exit ('no direct script entry is allowed'); Class Login Admin_Controller {Personal $ error = array (); Public function __ composition () {origin: __ creation (); } Public Function Index () {$ data ['title'] = 'administration'; $ This- & gt; Form_validation- & gt; Set_reales ('username', 'user name', 'required | callback_vidit'); $ This- & gt; Form_validation- & gt; Set_rels ('password', 'password', 'required'); If ($ ----- $ form_validation- & gt; Play ($ this) == incorrect) {$ this- & gt; Load-> View ('template / normal / login.tpl', $ data); } And {$ this- & gt; Load-> Model ('admin / user / model_user'); If ($ this-> Model_User-> GetStatus () == 1) {Redirect ('Admin / Dashboard'); } And {$ this- & gt; Session-> Set_flashdata ('Error', 'You have not been enabled by the webmaster. Please wait 24/48 hours if you need to contact the website master email.' 'Config_item (' config_email ')); Redirect ('admin'); }}} Validate public function () {$ this-> Load-> Library ('user'); If ($ this-> User-> Login () == FALSE) {$ this-> Form_validation- & gt; Set_message ('validate', '& lt; i class = "fa fa-exclamation-triangle"> does not match our database records!'); return false; } And {return true; }}}
No comments:
Post a Comment