2
注意:當我在Localhost中嘗試時,一切進展順利。CodeIgniter:找不到404頁面(在主機服務器中)
所以我有一個問題,當我想打電話給我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);
?>
當我嘗試在本地主機,一切都進展順利,平穩。 但是,當我嘗試在我的網絡服務器,每次我提交登錄表單,我直接進入404
感謝您的幫助:)
確保您的文件名以大寫字母開頭。所以你的Do_login文件應該是Do_login.php(首都D) – Craig
你在config.php的基礎URL是什麼?你重定向了哪個404? CI或服務器默認值。 –
@Craig:當然,我的所有控制器文件開頭大寫字母 – TableMan