• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
requested url not found, controller function not found

#1
Need help in fixing this error I encounter. I've been having this error for quite some time now.. The requested URL was not found on this server. Failed to load resource: the server responded with a status of 404 (Not Found). My url is below.

http://208.109.15.179/Login/loginUser

This is my code in the view:

Code:
<?php
                    echo form_open(
                        $action = 'Login/loginUser',
                        $params = array(
                            'id' => 'login_form',
                            'class'=>'needs-validation',
                            'method' => 'post'
                        )
                    );
                ?>
               


which calls the file Login.php under the controller folder. And this is the code:
Code:
<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Login extends CI_Controller
{
    public function index()
    {
        redirect(site_url());
    }

    private function loadLoginPage($header)
    {
        $this->load->view("includes/header", $header);
        $this->load->view("index/landingPage");
        return;
    }

    public function loginUser()
    {
        $header['title'] = 'RPFP - Login';
        if ($this->input->server(REQUEST_METHOD) != POST) {
            $this->loadLoginPage($header);
            return;
        }

        if ($this->LoginModel->isLoggedIn()) {
            redirect(site_url());
            return;
        }

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

        /* GET USER INPUT */
        $this->load->library('login/BasicUserCredentials');
        $cred = $this->basicusercredentials;
       
        $cred->UserName = $this->input->post(POST_USERNAME);
        $cred->Password = $this->input->post(POST_USERPASSWORD);

        /* VALIDATE INPUT */
        $this->form_validation->set_rules(POST_USERNAME, 'Username', REQUIRED);
        $this->form_validation->set_rules(POST_USERPASSWORD, 'Password', REQUIRED);

        if ($this->form_validation->run() == false) {
            $this->loadLoginPage($header);
            return;
        }
       
        /* CHECK DATABASE PASSWORD */
        if (!$this->LoginModel->login($cred)) {
            $this->form_validation->set_rules(POST_USERNAME, 'User Name', [REQUIRED, ['invalid_password', function () {
                $this->form_validation->set_message('invalid_password', 'Invalid Username or Password!');
                return false;
            }]]);

            if ($this->form_validation->run() == false) {
                $this->loadLoginPage($header);
                return;
            }
        }

        /* CHECK IF ACTIVE */
        if ($this->LoginModel->isDeactivated()) {
            $this->logoffUser();
            return;
        }

        redirect(site_url());
    }
}

I also enabled my htaccess file with the following code:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rpfp/

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]    

</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>
<FilesMatch ".(eot|otf|ttf|woff|woff2)">
    Header always set Access-Control-Allow-Origin "*"
</FilesMatch>

I'm already lost and I have been going around looking for answers. Hopefully someone may be able to understand this and give me suggestions.

Thank you,
Reply

#2
You can't use auto route with:
function loginUser()

Needs to be:
function loginuser()
Reply

#3
(07-27-2020, 09:00 AM)jreklund Wrote: You can't use auto route with:
function loginUser()

Needs to be:
function loginuser()


Appreciate your suggestion but I still get the same error.
Reply

#4
.htaccess needs to be this as well, based on the url given.
Code:
RewriteBase /
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.