The above PHP background login code implementation to avoid landing

Source: Internet
Author: User
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 ();   
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.