Thinkphp_ Simple Sign-in demo

Source: Internet
Author: User

1) front-desk login Template:

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTML>    <Head>        <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">        <title>Index</title>        <Linkrel= ' stylesheet 'type= ' Text/css 'href= ' __css__/basic.css '/>        <Scriptsrc= "__js__/basic.js"></Script>    </Head>    <Body>        <formAction= ' __url__/do_login 'Method= ' Post 'name= ' MyForm '>User name:<inputtype= ' text 'name= ' username '/><BR/>Password:<inputtype= ' Password 'name= ' Password '/><BR/>Verification Code:<inputtype= ' text 'name= ' Code '/>                    <imgsrc= "__app__/public/code"onclick= ' this.src=this.src+ '? " +math.random () '/>            </br/>            <imgsrc= ' __public__/images/login.gif 'onclick= "Sub ()"/>        </form>    </Body></HTML>

2) JS Verification and submit (Basic.js):

function Sub () {                var ou=document.myForm.username;                 var op=Document.myForm.password;                 var oc=Document.myForm.code;                 if (ou.value== "| | | op.value==" | | oc.value== ') {                    alert (' username or password or verification code cannot be null ');                } Else {                    document.myForm.submit ();                }            }

3) How to generate the CAPTCHA controller:

<? PHP     class extends action{        function  code () {        import (' ORG. Util.image ');            Image::buildimageverify ();        }    }

4) Login-processing controller:

<?PHPclassLoginactionextendsAction {functionindex () {$this-display (); }        functionDo_login () {//get the user name and password, and so on. And in the database, there is a user allowed to log on otherwise output error page            $username=$_post[' username ']; $password=$_post[' Password ']; $code=$_post[' Code ']; if($_session[' Verify ']!==MD5($code)){                $this->error (' Verification code Error! ‘); }            $m=m (' User '); $where[' username ']=$username; $where[' Password ']=$password; $i=$m->where ($where),Count(); if($i>0){                $this->redirect (' User/index '); }Else{                $this->error (' The user does not exist '); }        }    }

Thinkphp_ Simple Sign-in demo

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.