admin管理员组文章数量:1122832
Using codeigniter 3 I have modified the following. config
$config['base_url'] = '/';
$config['log_threshold'] = 4 ;
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
routes
$route['default_controller'] = 'Admin';
controller
class Admin extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('admin_model');
$this->load->helper('url');
$this->load->library("session");
$this->load->helper('form');
$this->load->library('form_validation');
}
public function index()
{
if(!$this->session->userdata('Usr_Mobile_No'))
{
redirect('admin/login');
}
$this->load->view('admin/index');
}
public function check_login()
{
//$name = $this->input->post('name');
$user_type = $this->input->post('user_type');
$mobile = $this->input->post('mobile');
$password = $this->input->post('password');
$admin_panel = $this->input->post('admin_panel');
$new_data = array('Usr_Mobile_No' => $mobile);
$this->session->set_userdata($new_data);
$sql1 = $this->admin_model->check_admin_login($user_type, $mobile, $password);
$redirect = base_url('admin/index');
$data['redirect'] = $redirect;
echo json_encode($data);
}
public function login()
{
$this->load->view('admin/login');
}
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
In my view folder I have login.php which has the following code
<form action="<?php echo base_url('admin/check_login'); ?>" method="post" id="signin_form" autocomplete="off"></form>
Update : I missed to add this line of code. It was already added.
On submit of this form I get "404 file or directory not found". I think it is trying to find check_login which is just a function. I also have an index.php in the view folder.
How do I debug this? Please advice.
Using codeigniter 3 I have modified the following. config
$config['base_url'] = 'http://demo.xyz.com/xyz/';
$config['log_threshold'] = 4 ;
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
routes
$route['default_controller'] = 'Admin';
controller
class Admin extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('admin_model');
$this->load->helper('url');
$this->load->library("session");
$this->load->helper('form');
$this->load->library('form_validation');
}
public function index()
{
if(!$this->session->userdata('Usr_Mobile_No'))
{
redirect('admin/login');
}
$this->load->view('admin/index');
}
public function check_login()
{
//$name = $this->input->post('name');
$user_type = $this->input->post('user_type');
$mobile = $this->input->post('mobile');
$password = $this->input->post('password');
$admin_panel = $this->input->post('admin_panel');
$new_data = array('Usr_Mobile_No' => $mobile);
$this->session->set_userdata($new_data);
$sql1 = $this->admin_model->check_admin_login($user_type, $mobile, $password);
$redirect = base_url('admin/index');
$data['redirect'] = $redirect;
echo json_encode($data);
}
public function login()
{
$this->load->view('admin/login');
}
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
In my view folder I have login.php which has the following code
<form action="<?php echo base_url('admin/check_login'); ?>" method="post" id="signin_form" autocomplete="off"></form>
Update : I missed to add this line of code. It was already added.
On submit of this form I get "404 file or directory not found". I think it is trying to find check_login which is just a function. I also have an index.php in the view folder.
How do I debug this? Please advice.
Share Improve this question edited yesterday adbury asked yesterday adburyadbury 478 bronze badges 1 |1 Answer
Reset to default 0You are almost there. Just add a login method in Admin Class.
<?php
class Admin extends CI_Controller
{
public function __construct()
{
parent::__construct();
//$this->load->model('admin_model');
$this->load->helper('url');
$this->load->library("session");
$this->load->helper('form');
$this->load->library('form_validation');
}
public function index()
{
if(!$this->session->userdata('Usr_Mobile_No'))
{
redirect('admin/login');
}
$this->load->view('admin/index');
}
public function login()
{
$this->load->view('login');
}
....
本文标签: phpWhy does my codeigniter 3 setup keep showing 404 errorStack Overflow
版权声明:本文标题:php - Why does my codeigniter 3 setup keep showing 404 error? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283454a1926975.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
if(!$this->session->userdata('Usr_Mobile_No'))
issue is with this – Abdulla Nilam Commented yesterday