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
  • if(!$this->session->userdata('Usr_Mobile_No')) issue is with this – Abdulla Nilam Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 0

You 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