1. Front Desk Ajax Data submission
<form id= "Login_form" action= "" method= "POST" >
<div class= "Login_frame" style= "position:relative";>
<div class= "Login_gl" style= "margin-top:35px;" >
<span class= "LOGIN_WZ" > Backend Management system </span>
</div>
<div class= "Login_user" >
<input id= "username" name= "username" type= "text" placeholder= "Please enter your username" value= "" style= "WIDTH:100%;HEIGHT:32PX; Border-style:none;font-size:16px;color: #959595; " />
</div>
<div class= "Login_user" >
<input id= "password" name= "password" type= "password" placeholder= "Please enter your password" value= "" style= "width:100%;height:32px ; Border-style:none;font-size:16px;color: #959595; " />
</div>
<div id= "login_btn" class= "Login_log" >
<span style= "FONT-SIZE:16PX;" > Login </span>
</div>
</div>
</form>
</div>
<script type= "Text/javascript" >
$ ("#login_btn"). Click (function () {
var username = $.trim ($ ("#username"). Val ());
var password = $.trim ($ ("#password"). Val ());
if (username = = "") {
Alert ("Please enter user name");
return false;
}else if (password = = "") {
Alert ("Please enter password");
return false;
}
Ajax to server-side verification
var data= {Username:username,password:password};
$.ajax ({
Type: "POST",
URL: "__controller__/check_login",
Data:data,
DataType: ' JSON ',
Success:function (msg) {
Alert (msg);
if (msg==1) {
Window.location.href = "{: U (' index/personal ')}";
}else{
Alert ("Login failed, please try again!");
}
}
});
});
</script>
2. Background check:
* */
Public Function Check_login () {
$password =i (' Param.password ');
$username =i (' param.username ');
$data ["Name"]= $username;
$user =m (' systemuser ');
$list = $user->where ($data)->find ();
$return = 0;
if ($list! = "") {
if ($list [' Password ']==md5 ($password) && $list [' status '] = = 1) {
Logon time and login IP
$public = new Publiccontroller ();
$lastlogonip = $public->ip_address ();
$time = $time =date ("y-m-d h:i:s", Time ());
$where =array (' id ' = + $list [' id ']);
$user->where ($where)->save (Array (' lastlogonip ' = $lastlogonip, ' lastlogontime ' = $time));
$this->login ($list);
$return =1;//Login Successful
}
}else{
$return =2;//Logon Failure
}
$this->ajaxreturn ($return);
}
3. Sign Out:
Sign out:<a href= "{: U (' Login/login ')}"> <img src= "/public/images/ Tuichu.png "> </a>
Login (Ajax submit data and background check)