[php]代码库
/**
* 用户登录
*
* @return int
*/
public function login()
{
//获取帐号信息
$name=I('post.username');
$pwd=md5(I('post.password'));
$Suppliers=M('User_suppliers');
$supplier=$Suppliers->field('name,id,rank,log_times,supplier_id')
->where("`status`='normal' and `password`='$pwd' and (`name`='$name' or `email`='$name' or `mobile`='$name')")
->find();
if(empty($supplier)){
return 100;
}
//更新状态值
$datetime=date('Y-m-d H:i:s');
$data_array=array(
'id'=>$supplier['id'],
'log_times' => $supplier['log_times']+1,
'loginip' => get_client_ip(),
'logindate' => $datetime
);
$Suppliers->save($data_array);
$session['id']=$supplier['id'];
$session['name']=$supplier['name'];
$session['rank']=$supplier['rank'];
$session['suppid']=$supplier['supplier_id'];
session('user',$session);
return 101;
}