Created
March 6, 2014 13:24
-
-
Save no13bus/9389605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function login() | |
{ | |
if(!IS_POST) $this->redirect('index',array('errormsg' => '非法请求')); | |
$email = I('email'); | |
$last_login = date(time(),"Y-m-d,H:i:s"); | |
$password = I('password','','md5'); | |
/////find只会找到一条记录 这个是和select不同的地方 这找到的是一个集合 | |
$user = M('user')->where(array('email' => $email))->find(); | |
if (!$user || $user['password']!= $password) { | |
$this->error('用户名不存在或者密码不正确'); | |
} | |
session('username',$user['username']); | |
session('email',$user['email']); | |
session('uid',$user['uid']); | |
//////cookie | |
$auto = $user['uid'] . '|' . $user['username']; | |
cookie('auto',$auto,3600); | |
$data = array( | |
'uid' => $user['uid'], | |
'username' => $user['username'], | |
'email' => $user['email'], | |
'last_login' => date("Y-m-d H:i:s",time()), | |
); | |
$user = M('user')->data($data)->save();///uid important | |
$this->redirect('Index/Index/index'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment