1

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. Update Server is running php 8.3.

How do I debug this? Please advice. Page gets stuck at this point

1
  • if(!$this->session->userdata('Usr_Mobile_No')) issue is with this Commented Jan 6 at 6:22

2 Answers 2

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');
    }
....
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the reply. That line was code already exists in the controller. My mistake that I missed to add it to my question. I have updated my query.
Hello, Seems like something is wrong in jquery post. Would you please share the form submit code function for better insight.
I don't think there is anything wrong with the submit code. there are 3 methods in the controller. index(), login(), and check_login(). Only the check login method is "not found". I have tried removing all the code in the submit function and just call the method on its click. Still its not working.
0

This may not be the answer anyone is looking for but Just to make sure why the code is not working I would like to inform that running CI3 on PHP>=8 is near impossible. Atleast it Is for me. If you have CI3 project, either downgrade your php version to less than 7 or upgrade your project to CI4. Even still there are a lot of tweaks to be performed on your code for it to work with CI4. But its better than fixing CI3 on php>8.

If anybody can provide a better answer I am willing to withdraw this as the selected answer.

That's all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.