Welcome Guest, Not a member yet? Register   Sign In
404 Not found Error
#1

Hello everyone,
Please help me figure this out. I am new to codeigniter, I was given a project by my supervisor to localize a project into my native language, where I need to change some forms into my native language. I have gone through some tutorials and books and got myself educated a little on codeigniter MVC framework. I am stuck with this problem, the first page of the application is a login page, after submitting the login form I get this error
Code:
Not Found
The requested URL /accounting/accounting/login/user_login was not found on this server.
I am not sure where/and why this error is coming from, since the files I received for the project are from an already up and running application. These are the things I checked to make sure the application config is correct.

Base url is set correct

1. It is set to $config['base_url'] = 'http://localhost/accounting';

2. Database connection is correctly configured

3. VirtualHOst configuration in "C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-hosts
Code:
<VirtualHost *:80>
     DocumentRoot "c:/wamp/www"
     ServerName localhost
     ServerAlias localhost
     <Directory  "c:/wamp/www">
        AllowOverride All
        Require local
     </Directory>
</VirtualHost>

<VirtualHost *:80>
     DocumentRoot "c:/wamp/www/accounting"
     ServerName accounting.dev
     <Directory  "c:/wamp/www/accounting">
        AllowOverride All
        Require local
     </Directory>
</VirtualHost>
And the code shown below is from view/login.php
Code:
<legend>LOG IN</legend>
<form action="<?= site_url('/accounting/login/user_login'); ?>" method="post" style="color:black;margin:1%">
<label class="label">User Name</label><input type ='text' name='username' style="background:transparent" class="textbox">
<label class="label">Password</label><input type ='password' name='password' style="background:transparent" class="textbox">
<input type='submit' value='Submit' name="enter" style="margin-top:2%;" class="button">
    </form>
controller/login.php
Code:
class Login extends CI_Controller
{
    function __construct()
    {
        parent:: __construct();
        $this->load->model('login_model');
        $this->load->model('form_model');
    }

    public function index()
    {
        $datah['title'] = "Saseco | Login"; //For Title
        
        $this->load->view('includes/header',$datah);
        $this->load->view('login');
        $this->load->view('includes/footer');
    }
    
    public function home_main()
    {
        
        $this->load->view('ifile');
        
        
    }


    public function home()
    {

        $datah['title'] = "Saseco|| Home"; //For Title
            
        // echo "<pre>";
        // print_r($data);exit;

        
        $this->load->view('includes/header',$datah);
        $this->load->view('includes/leftmenu');
        $this->load->view('homepage',$data);
        $this->load->view('includes/footer');    
    }    
    function user_login()
    {
        if(isset($_POST['enter']))    //Login button pressed
        {
            $data = $_POST;
            $check = $this->login_model->login_match($data);
    if($check)
            {
                redirect('login/home_main');
                // redirect('login/home');
            }
            else
            {
                echo'<script type="text/javascript">
                    alert("Invalid Username or Password");
                </script>';
                
                $datah['title'] = "Sasec | Login"; //For Title
        
                    $this->load->view('includes/header',$datah);
                    $this->load->view('login');
                    $this->load->view('includes/footer');
            }
        }
    }
    function logout()
    {    
        $this->login_model->logout();
        $this->session->sess_destroy();
        echo'<script type="text/javascript">
                    alert("You Have Successfully Logged Out..");
                </script>';
                                $datah['title'] = "Saseco | Login"; //For Title
                       $this->load->view('includes/header',$datah);
                    $this->load->view('login');
                    $this->load->view('includes/footer');        
            }
}

?>
model/login_model.php
Code:
class Login_model extends CI_Model
{
    function __construct()
    {
        parent:: __construct();
    }
    
    function login_match($input)
    {
        $this->db->select('username, password');
        $this->db->from('user_login');
        $this->db->where('username', $input['username']);
        $this->db->where('password', $input['password']);
        $this->db->where('sts', '1');
        
        $query = $this->db->get();

        // echo "1";
        if($query-> num_rows() == 1)
        {
            
            $data=$this->db->get_where('user_login',array('username =' => $input['username']));
            $data=$data->row_array();
            //$data=$data_id;
            $this->db->insert('user_log',array('name'=> $input['username'], 'user_date' => date('Y-m-j'), 'user_time' => date('H:i:s'), 'log' => 'Login', 'till' => date('H:i:s'), 'time' => 0));
            $data['log_id']=$this->db->insert_id();
            $this->session->set_userdata('logged_in',$data);
            $this->session->set_userdata('menu_show','4');

            //echo "<pre>";
            //print_r($data);exit;
            
            return true;
        }
        else
        {
            
            return false;
        }
        
    }
    function logout()
    {
        $session_user=$this->session->userdata('logged_in');
        $this->db->insert('user_log',array('name'=> $session_user['username'], 'user_date' => date('Y-m-j'), 'user_time' => date('H:i:s'), 'log' => 'Logout'));
    }
    
}

?>
The .htaccess file
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I have one more .htaccess file in applications folder with the setting
[code]
deny from all
And finally what should i write in here ajax.js
Code:
function base_url()
    {
        var newURL = window.location.protocol + "//" + window.location.host+"/accounting/";

        return newURL;
    }

Is "/accounting/" correct, am I supposed to change it to "/localhost/" if I save the project files in the root directory xamp/www. Hope somebody will help me on this. Thank you
[/code]
Reply
#2

Quote:1. It is set to $config['base_url'] = 'http://localhost/accounting';

This is probably the problem. More than likely, the base URL should simply be http://localhost/ (and in that case, you could leave it empty), unless you have specifically configured the local server to use the URL http://localhost/accounting/ as the base URL for this site.

For a localization project, you shouldn't have to change any code once you have the site configured correctly in your development environment, unless they have never localized the site into any other languages (in which case you may have to create language strings for the site's original language and the new language and ensure that views and controllers use the language strings instead of hard-coded text).
Reply
#3

(This post was last modified: 05-20-2015, 11:12 AM by karmad. Edit Reason: rephrased my answer )

(05-20-2015, 10:10 AM)mwhitney Wrote:
Quote:1. It is set to $config['base_url'] = 'http://localhost/accounting';

This is probably the problem. More than likely, the base URL should simply be http://localhost/ (and in that case, you could leave it empty), unless you have specifically configured the local server to use the URL http://localhost/accounting/ as the base URL for this site.

For a localization project, you shouldn't have to change any code once you have the site configured correctly in your development environment, unless they have never localized the site into any other languages (in which case you may have to create language strings for the site's original language and the new language and ensure that views and controllers use the language strings instead of hard-coded text).

Thank you @mwhitney for the response. I have solved the problem, the problem was with my .htaccess file. I only had to change the RewriteBase / to RewriteBase /accounting/ .     Since my virtual host is set to accounting.dev I have set the base_url parameter to $config[base_url]='http://localhost/accounting'. For me it works this way. Thank you for the response!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB