Codeigniter - 404 Page not found

I am using Codeigniter. Everything is fine until I create a new controller named user_authentication.php (located at http: //localhost/etalasekursusci/index.php/user_authentication ). When I try to open this controller, the browser said "404 Page not found. The page you requested was not found." My controller files at http: //localhost/etalasekursusci/index.php/controller and http: //localhost/etalasekursusci/index.php/user work fine, only the one that fails.

(FYI, I copy the user_authentication.php file from my friend. And if I copy the script class inside the custom class to the user_authentication class, access to user_authentication.php ...)

File / application / .htaccess:

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

      

File / application / config / config.php:

$config['base_url'] = 'http://localhost/etalasekursusci/';

      

File / application / config / routes.php:

$route['default_controller'] = 'controller';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

      

File / application / controllers / user.php (can be accessed):

<?php
class user extends CI_Controller {
public function __construct()
{
    parent::__construct();

    $this->load->model('user_model');
}

public function index()
{
    $this->load->library('form_validation');

    $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

    $this->form_validation->set_rules('nama', 'Nama Kursus', 'required|min_length[5]|max_length[20]');

    $this->form_validation->set_rules('alamat', 'Alamat Kursus', 'required|min_length[5]|max_length[40]');

    if ($this->form_validation->run() == FALSE)
    {
        $this->load->view('register_user');
    }
    else
    {
        $data = array(
        'lembaga' => $this->input->post('nama'),
        'alamat' => $this->input->post('alamat'),
        'paketkursus' => $this->input->post('paket'),
        'lokasi' => $this->input->post('lokasi'),
        'harga' => $this->input->post('biaya')
        );

        $this->user_model->insert_userinfo($data);

        $this->load->view('tambahberhasil');

    }
}
}

      

File / application / controllers / user_authentication.php (which cannot be accessed):

<?php
class user_authentication extends CI_Controller {

public function __construct() {
parent::__construct();


$this->load->helper('form');


$this->load->library('form_validation');


$this->load->library('session');


$this->load->model('login_database');

}


public function user_login_show() {
$this->load->view('login_form');
}

public function user_registration_show() {
$this->load->view('registration_form');
}

public function new_user_registration() {

$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

$this->form_validation->set_rules('name', 'Name', 'required|min_length[5]|max_length[20]');

$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[40]');

$this->form_validation->set_rules('email_value', 'Email', 'required|min_length[2]|max_length[50]');

$this->form_validation->set_rules('password', 'Password', 'required|min_length[6]|max_length[10]');

if ($this->form_validation->run() == FALSE) {
$this->load->view('registration_form');
} else {
$data = array(
'name' => $this->input->post('name'),
'user_name' => $this->input->post('username'),
'user_email' => $this->input->post('email_value'),
'user_password' => $this->input->post('password')
);
$result = $this->login_database->registration_insert($data) ;
if ($result == TRUE) {
$data['message_display'] = 'Registrasi Berhasil !';
$this->load->view('login_form', $data);
} else {
$data['message_display'] = 'Username yang ada inputkan sudah ada!';
$this->load->view('registration_form', $data);
}
}
}


public function user_login_process() {

$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[20]');

$this->form_validation->set_rules('password', 'Password', 'required|min_length[5]|max_length[40]');

if ($this->form_validation->run() == FALSE) {
$this->load->view('login_form');
} else {
$data = array(
'username' => $this->input->post('username'),
'password' => $this->input->post('password')
);
$result = $this->login_database->login($data);
if($result == TRUE){
$sess_array = array(
'username' => $this->input->post('username')
);

$this->session->set_userdata('logged_in', $sess_array);
$result = $this->login_database->read_user_information($sess_array);
if($result != false){
$data = array(
'name' =>$result[0]->name,
'username' =>$result[0]->user_name,
'email' =>$result[0]->user_email,
'password' =>$result[0]->user_password
);
$this->load->view('admin_page', $data);
}
}else{
$data = array(
'error_message' => 'Nama atau Password yang anda masukan salah !'
);
$this->load->view('login_form', $data);
}
}
}


public function logout() {

$sess_array = array(
'username' => ''
);
$this->session->unset_userdata('logged_in', $sess_array);
$data['message_display'] = 'Anda sudah Log Out !';
$this->load->view('login_form', $data);
}

}

      

Any ideas?

(FYI, I copy the user_authentication.php file from my friend. And if I copy the script class inside the custom class to the user_authentication class, access to user_authentication.php ...)

+3


source to share


2 answers


Since you have defined the base url as

$config['base_url'] = 'http://localhost/etalasekursusci/';

      

Try url http: // localhost / etalasekursusci / user_authentication without index.php



OR Define base_url in the config as shown below: index.php

$ config ['base_url'] = ' http: //localhost/etalasekursusci/index.php ';

Please write the controller code if you can.

+3


source


In Codeigniter 3, your class names must start with an uppercase letter, just like their filename.

You should try renaming user_authentication.php

to user_authentication.php

and changing the initial lines to:

<?php
class User_authentication extends CI_Controller {

      



similarly, user.php

it should be changed to user.php

and its opening lines:

<?php
class User extends CI_Controller {

      

Documentation for this description can be found here

+3


source







All Articles