【发布时间】:2018-12-15 00:23:13
【问题描述】:
与其类同名的方法在 PHP 的未来版本中将不再是构造函数,login 的构造函数严重性已弃用:8192
我在登录 php 文件的第 3 行和第 26 行出现错误 第 26 行错误:未定义属性:login::$load 我收到了错误
我的代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
类登录扩展 CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('login');
}
function login(){
$data ["title"] = "CodeIgniter Simple Login Form with session";
$this->load->view("login", data);
}
function login_validation(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Kullanýcý Adý', 'required');
$this->form_validation->set_rules('password', 'password', 'required');
if($this->form_validation->run())
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('login_model');
if($this->login_model->can_login($username, $password))
{
$session_data = array(
'username' => $username
);
$this->session->set_userdata($session_data);
redirect(base_url("login/enter"));
}else{
$this->session->flash_data('error' , 'Invalid Username and Password');
redirect(base_url("login"));
}
}else
{
$this->login();
}
function enter()
{
if($this->session->userdata('username') != ''){
redirect(base_url("dashboard"));
}else{
redirect(base_url("login"));
}
}
}
} ?>
【问题讨论】:
-
在你的控制器或
autoload.php中加载url助手
标签: javascript php codeigniter