luofeng0603
2016-03-16 16:06
按老师课程编写执行之后,报一个错误,百思不得其解,请求指点
附上authModel.class.php代码:
<?php
class authModel{
private $auth = '';
public function __construct(){
//判断当前是否已经登录
if($_SESSION['auth']&&(!empty($_SESSION['auth']))){
$this -> auth = $_SESSION['auth'];
}
}
//定义登录验证的方法
public function loginsubmit(){
if(empty($_POST['username'])||empty($_POST['password'])){
return false;
}
$username = daddslashes($_POST['username']);
$password = daddslashes($_POST['password']);
if($this->auth = $this->checkuser($username,$password)){
$_SESSION['auth'] = $this->auth;
return true;
}else{
return false;
}
}
public function checkuser($username,$password){
$auth = M('admin')->findOne_by_username($username);
if($auth&&$password == $auth['password']){
return $auth;
}else{
return false;
}
}
public function getAuth(){
return $this->auth;
}
}
?>
已经排查解决,if($_SESSION['auth']&&(!empty($_SESSION['auth'])))改成if(isset($_SESSION['auth'])&&(!empty($_SESSION['auth'])))后解决了
这个应该是提醒,不算真正的错误,可以加@屏蔽掉
MVC架构模式分析与设计
82400 学习 · 929 问题
相似问题