<?php/** * Background Login controller */class loginaction extends action{/** * Login View */Public Function index () { $this->display (); Public Function Login () {//if (!is_post) Halt (' page does not exist '); if (' Code ', ' ', ' MD5 ')! = Session (' verify ') {$this->error (' captcha error '); } $username = I (' username '); $pwd = I (' Password ', ' ', ' MD5 '); $user =m (' member ')->where (Array (' username ' = $username))->find (); if (! $user | | $user [' password ']! = $pwd) {$this->error (' account name or password is incorrect! ‘); } if ($user [' Lock ']) $this->error (' Account Locked '); $data = array (' id ' = = $user [' id '], ' Logintime ' =>time (), ' Loginip ' =>get_client_ip (),//Get IP Address ); M (' member ')->save ($data);//Update Database contents session (' UID ', $user [' id ']); Session (' username ', $user [' username ']); Session (' Logintime ', date (' y-m-d h:i:s ', $user [' Logintime '])); Session (' Loginip ', $user [' Loginip ']); $this->redirect (' AdmiN/index/index '); /** * * * * * * * * */Public Function verify () {//Make sure GD2 Library opens import (' ORG. Util.image '); Image::buildimageverify ("PNG"); }}?>
thinkphp Login Function code