The following PHP background login code to achieve free login
If the background administrator account is admin, password is 123456 How to realize the following code how to implement the free login, trouble to know the elder brother directly to the code thank you
PHP Code
Display (App_path. ' /public/admin/login.html '); }//Generate the CAPTCHA public function Vcode () {Import ("ORG. Util.image "); Image::buildimageverify ();//6,0, ' png ', 1,20, ' verify '}//Login detection public Function check () {if (Empty ($_post[ ' user_name ']) {$this->error (' account must be! ');} if (Empty ($_post[' user_pwd ')) {$this->error (' Password must be! ');} if (function_exists (' Gd_info ')) {if (Empty ($_post[' verify ')) {$this->error (' Verification code must! ');} if ($_session[' verify ']!=md5 ($_post[' verify ')) {$this->error (' Captcha is wrong! ');} }//Generate Authentication Conditions $map =array (); Support to login with a bound account $map [' admin_name ']=$_post[' user_name ']; $map ["User_status"]=array (' GT ', 0);//Status $rs =d ("Admin.admin"); $authInfo = $rs->where ($map)->find (); Use the user name, password, and status to authenticate if (false = = = $authInfo) {$this->error (' account not present or disabled! '); }else {if ($authInfo [' Admin_pwd ']!=md5 ($_post[' user_pwd ')) {$thisError (' Password is wrong! '); }//Cache access Rights $_session[c (' User_auth_key ')]= $authInfo [' admin_id ']; $_session[' ADMIN_OK ']= $authInfo [' ADMIN_OK ']; $_session[' admin_name ']= $authInfo [' Admin_name ']; $_session[' email ']= $authInfo [' Admin_email ']; $_session[' lastlogintime ']= $authInfo [' admin_logintime ']; $_session[' Login_count ']= $authInfo [' Admin_count ']; if ($authInfo [' user_name ']== ' admin ') {//$_session[' Administrator '] = true; }//Save login Information $ip =get_client_ip (); $data =array (); $data [' admin_id ']= $authInfo [' admin_id ']; $data [' Admin_logintime ']=time (); $data [' Admin_count ']=array (' exp ', ' admin_count+1 '); $data [' Admin_ip ']=get_client_ip (); $rs->save ($data); Redirect (' Index.php?s=admin-index '); }}//user logged out public functionLogout () {if (Isset ($_session[c (' User_auth_key ')]) {unset ($_session[c (' User_auth_key ')]); Unset ($_session); Session_destroy (); $this->assign (' Jumpurl ', ' index.php?s=admin-login '); $this->success (' Log out success! '); }else {$this->error (' already logged out! '); }}}?>
------Solution--------------------
Rewrite the index method to
PHP Code
Public Function Index () { if ($_session[c (' User_auth_key ')]) { Redirect ("Index.php?s=admin-index"); } $this->display (App_path. ' /public/admin/login.html '); $_post[' user_name ' = ' admin '; $_post[' user_pwd '] = ' 123456 '; $_post[' verify '] = 1; $_session[' Verify ' = MD5 ($_post[' verify ']); $this->check (); }