auth報錯
按老師課程編寫執行之后,報一個錯誤,百思不得其解,請求指點
附上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;
}
}
?>
2016-03-21
已經排查解決,if($_SESSION['auth']&&(!empty($_SESSION['auth'])))改成if(isset($_SESSION['auth'])&&(!empty($_SESSION['auth'])))后解決了
2016-03-18
這個應該是提醒,不算真正的錯誤,可以加@屏蔽掉