404 Not Found after submit login page in codeigniter -


codeigniter load login page when submit form, browser response 404 not found. have no idea real problem. please help. below our codes:

this view file : view/login/index.php

<?= form_open(base_url().'login/index', array('id' => 'loginform')) ?> <div class="wrap-login">     <div id="content1">         <div id="main">             <h1>administrator area</h1>             <div class="full_w1">         <div class="form">                 <?php if ($this->session->flashdata('message')) : ?>                 <?= $this->session->flashdata('message') ?>                 <?php endif; ?>                 <?= form_label(lang('username'), 'username', array('data-icon' => 'u')) ?>                 <?= form_input(array('name'=>'username','id'=>'username','value'=>set_value('username'),'class'=>'text','placeholder'=>'enter username')) ?>                 <?= form_error('username') ?>                  <?= form_label(lang('password'), 'password', array('data-icon' => 'p')) ?>                 <?= form_input(array('type'=>'password','name'=>'password','id'=>'password','class'=>'text','placeholder'=>'enter password')) ?>                 <?= form_error('password') ?>                     <div class="sep"></div>                                    <?= form_submit('login', lang('login'), 'class="ok"' ) ?>                 </div></div>             </div>         </div>     </div>      <?=form_close()?> <script type="text/javascript">     $(document).ready(function()     {         $('#username').focus();     }); </script> 

this controller file : controller/login

<?php if ( ! defined('basepath')) exit('no direct script access allowed');  class login extends ci_controller {      /**      * index page controller.      *      * maps following url      *      http://example.com/index.php/welcome      *  - or -        *      http://example.com/index.php/welcome/index      *  - or -      * since controller set default controller in       * config/routes.php, it's displayed @ http://example.com/      *      * other public methods not prefixed underscore      * map /index.php/welcome/<method_name>      * @see http://codeigniter.com/user_guide/general/urls.html      */      function __construct()     {         parent::__construct();          // load model         $this->load->model('login_model','',true);     }      public function index()     {         if ($this->privilege->logged_in){             redirect('dashboard/');                  }          // set validation rules         $valid = array(                    array(                          'field'   => 'username',                           'label'   => lang('username'),                           'rules'   => 'trim|required|min_length[4]|max_length[15]|xss_clean'                    ),                    array(                          'field'   => 'password',                           'label'   => lang('password'),                           'rules'   => 'trim|required|md5'                    )                  );          $this->form_validation->set_rules($valid);         $this->form_validation->set_error_delimiters('<div class="error">','</div>');          // has form been submitted , valid form info (not empty values)         if($this->input->post('login'))         {echo "hi";die;             if($this->form_validation->run())             {                 $returnvalue = $this->login_model->authenticate();                 if($returnvalue == 'active')                 {                     //echo "<pre>"; print_r($this->session->userdata('sessionkey')); echo "</pre>"; die;                     $this->session->set_flashdata('message','<div class="alert success" id="msgdiv"><span class="hide" id="hidemsg">x</span>you have logged-in!!</div>');                     redirect('dashboard/');                 }                 else                 {                     $this->session->set_flashdata('message', '<div class="error">'.lang($returnvalue).'</div>');                     redirect('login/');                 }             }         }         $data['title'] = "administrator area";         $this->load->view('common/login-header',$data);         $this->load->view('login/index');         //$this->load->view('common/footer');     }      public function logout()     {         if($this->session->sess_destroy()) {             $this->session->set_flashdata('message','<div class="alert success" id="msgdiv"><span class="hide" id="hidemsg">x</span>you have logged-out!!</div>');             redirect('login/');         }         else {             redirect('dashboard/');         }     } } 

here working code after modifying

change form action 'http://85.195.86.86/index.php/login/index'

enter image description here

and here 'hi!' :)

enter image description here

summery: if want use existing 'url' remove 'index.php' 'url' .htaccess. can serch on google 'how remove index.php in ci'

.htaccess code:

options -indexes options +followsymlinks  rewriteengine on  #removes access system folder users. #additionally allow create system.php controller,  rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ index.php?/$1 [l]  #when application folder isn't in system folder  rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ /index.php?/$1 [l]  #checks see if user attempting access valid file, #such image or css document, if isn't true sends #request index.php  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l]  # if don't have mod_rewrite installed, 404's # can sent index.php, , works normal. # submitted by: elliothaughin     errordocument 404 /index.php 

ci config file changes:

$config['base_url'] = '';  $config['index_page'] = ''; 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -