我的表单在提交时加载 Auth 控制器类的登录方法,并且我有具有身份验证功能的 AuthData 模型。现在,当用户提交表单时,我收到错误?
警告是——
遇到 PHP 错误
严重性:通知
消息:未定义属性:Auth::$AuthData
文件名:controllers/Auth.php 行号:21回溯:
文件:C:\xampp\htdocs\Trials\application\controllers\Auth.php 行:21 函数:_error_handler
文件:C:\xampp\htdocs\Trials\index.php 行:315 函数:require_once错误 遇到未捕获的异常
类型:错误
消息:在 null 上调用成员函数authenticate()
文件名:C:\xampp\htdocs\Trials\application\controllers\Auth.php 行号:21回溯:
文件:C:\xampp\htdocs\Trials\index.php 行:315 函数:require_once
这是我的控制器
<?php
//defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
$this->load->model('AuthData');
$this->load->helper('url');
// needed ???
$this->load->database();
}
public function login()
{
$user = $this->input->post('username');
$pass = $this->input->post('password');
$input = array( 'username'=>$user, 'password'=>$pass);
$data['loggedIn'] = "no";
$chk = $this->AuthData->authenticate($input);
if($chk) …Run Code Online (Sandbox Code Playgroud)