【发布时间】:2015-07-21 20:07:49
【问题描述】:
注意:当我在 Localhost 中尝试时一切顺利。
所以当我想在我的登录表单中调用我的 do_login 控制器时遇到了问题。
这是我的控制器:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Do_login extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('login_model', '', TRUE);
}
public function index()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'email', 'trim|required');
$this->form_validation->set_rules('password', 'password', 'trim|required|callback_check_database');
if($this->form_validation->run() == FALSE)
{
$this->load->view('admin/login_view');
}
else
{
redirect('home', 'refresh');
}
}
public function check_database($password)
{
$email = $this->input->post('email', TRUE);
$result = $this->login_model->check_login($email, $password);
if($result)
{
$sess_array = array();
foreach($result as $row)
{
$sess_array = array(
'user_id' => $row->user_id,
'email' => $row->email
);
$this->session->set_userdata('logged_in', $sess_array);
}
return TRUE;
}
else
{
$this->form_validation->set_message('check_database', 'Email / Password salah');
return FALSE;
}
}
}
?>
这是我的看法:
<?php
$attributes = array('class' => 'form-signin', 'id' => 'myform');
echo form_open('do_login', $attributes);
?>
当我在 Localhost 中尝试时,一切都很顺利。 但是当我在我的网络服务器上尝试时,每次我提交登录表单时,我都会直接进入 404。
感谢您的帮助:)
【问题讨论】:
-
确保您的文件名以大写字母开头。所以你的 Do_login 文件,应该是 Do_login.php(大写 D)
-
您在 config.php 的基本网址是什么?你重定向了哪个404? CI 或服务器默认值。
-
@Craig : 当然我所有的控制器文件都以大写字母开头
-
$config['base_url'] 检查 config.php 文件中的内容
-
yaa url 已打开,这不是 cofig.php 文件的包含
标签: php codeigniter url