gpt4 book ai didi

CodeIgniter - 在非对象上调用成员函数 model()

转载 作者:可可西里 更新时间:2023-10-31 23:53:47 24 4
gpt4 key购买 nike

<分区>

我有一个正在 View 中创建的登录表单。然后在我的 Controller 中,我试图加载我的模型,但它似乎没有加载。在 stackoverflow 上查找了一些答案,几乎每个人都说自动加载模型、导入数据库库等。我这样做了,但我仍然收到错误

    Fatal error: Call to a member function model() on a non-object in C:\xampp\htdocs\\project\application\controllers\login.php on line 11 

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Login::$load

Filename: controllers/login.php

Line Number: 11

登录 View

<?php
$loginEmail = array('placeholder' => "Email", 'name' => "loginEmail");
$loginPassword = array('placeholder' => "Wachtwoord", 'name' => "loginPassword");
$loginSubmit = array('name' => "loginSubmit", 'class' => "btn", 'value' => "Inloggen");
$loginForgot = array('name' => "loginForgot", 'class' => "link", 'value' => "Wachtwoord vergeten?");

echo form_open('login/login', array('class' => 'grid-100 formc'));
echo form_input($loginEmail);
echo form_password($loginPassword);
echo form_submit($loginSubmit);
echo form_submit($loginForgot);
?>

登录 Controller

<?php

Class Login extends CI_Controller{
function index(){
$data['content'] = 'login_view';
$this->load->view('templates/template', $data);
}


function login(){
$this->load->model('login_model');
$query = $this->login_model->validate();

if($query){
$data = array(
'username' => $this->input->post('loginEmail'),
'loggedin' => true

);

$this->session->set_userdata($data);
redirect('profile/myprofile');
}
}

}

?>

登录模型

<?php

Class Login_model extends CI_Model{

function validate(){
$this->db->where('email', $this->input->post('loginEmail'));
$this->db->where('password', md5($this->input->post('loginPassword')));

$query = $this->db->get('tbl_users');

if($query->num_rows == 1){
return true;
}
}

}

?>

autoload.php

$autoload['libraries'] = array('database', 'session');

我在这里错过了什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com