我想知道是否有人可以帮助我???我正在使用 CodeIgniter 创建一个小的登录屏幕。但是,每次我调用该函数以使用 CodeIgniter 表单助手验证详细信息时。404 错误一直显示 CodeIgniter 找不到 URL。我的“查看”文件代码如下所示:
<!doctype html>
<html>
<head>
<title>CodeIgniter Prototype</title>
<!-- CSS/LESS Code Links -->
<link rel = "stylesheet" href = "<?php echo base_url();?>css/style.css" type = "text/css"/>
</head>
<body>
<div class = "login_wrapper">
<h1>ONESG OneInvoice Exporter</h1>
<?php
echo form_open('login/check_login');
echo form_input('username', '', 'placeholder = "Enter Username"');
echo form_password('password', '', 'placeholder = "Enter Password"');
echo form_submit('submit', 'Login');
echo form_close();
?>
</div>
</body>
</html>
我的控制器代码如下所示:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
public function index() {
$this->load->view('login_form');
}
public function check_login() {
$this->load->model('login_model');
$query = $this->login_model->validate();
if ($query) {
$data = array (
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->sessions->set_userdata($data);
redirect('site/members_area');
}
else {
$this->index();
}
}
}