我想知道是否有人可以帮助我???我正在使用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();
}
}
}
答案 0 :(得分:0)
在.htaccess中添加
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
然后在config add中的routes.php中添加
$route["members_area/(.*)"] = 'site/members_area/$1';
答案 1 :(得分:0)