Q:

CodeIgniter 3.0.2 does not login with old code

User_log.php (This is controller File)
<?php

class User_log extends CI_Controller 
{
public function __construct()
{
    parent::__construct();
    $this->load->model('user_data');
}
public function index($msg = NULL)
{
    $data['msg'] = $msg;
    $data['title'] = "My Real Title";
    $data['heading'] = "My Real Heading";
    $data['attribute'] = array('name' => 'process');
    $data['data'] = array(
    'name'          => 'username',
    'id'            => 'username',
    );
    $data['pass'] = array(
    'name'          => 'password',
    'id'            => 'password',
    );

    $this->load->view('login', $data);
}
public function process()
{
    // Load the model
    $this->load->model('user_data');
    // Validate the user can login
    $result = $this->user_data->validate();
    // Now we verify the result
    if(! $result){
        // If user did not validate, then show them login page again
        $msg = '<font color=red>Invalid username and/or password.</font><br />';
        $this->index($msg);
    }else{
        // If user did validate, 
        // Send them to members area
        redirect('success');
    }        
}
}

User_data.php (This is model file)
 <?php

 class User_data extends CI_Model 
 {
 public function __construct()
 {
    parent::__construct();
 }
    public function validate()
    {
        $username = $this->security->xss_clean($this->input-   >post('username'));
        $password = $this->security->xss_clean($this->input-     >post('password'));

        $this->db->where('username', $username);
        $this->db->where('password', $password);

        $query = $this->db->get('user');

        if($query->num_rows == 1)
        {
            // If there is a user, then create session data
            $row = $query->row();
            $data = array(
                    'id' => $row->id,
                    'username' => $row->username,
                    'validated' => true
                    );
            $this->session->set_userdata($data);
            return true;
        }

        return false;
    }
    }

login.php (This is view file)
<head>    
<title>Jotorres Login Screen | Welcome </title>
</head>
<body>
<div id='login_form'>
    <form action='<?php echo base_url();?>index.php/blog/process'      method='post' name='process'>
        <h2>User Login</h2>
        <br />            
        <label for='username'>Username</label>
        <input type='text' name='username' id='username' size='25' /><br />

        <label for='password'>Password</label>
        <input type='password' name='password' id='password' size='25' /><br   />                            

        <input type='Submit' value='Login' />            
    </form>
  </div>
 </body>
 </html>

Where is the problem of this code? Is not working properly in CodeIgniter version 3.0.

A:

According to the code provided, your form action is wrong.
<form action='<?php echo base_url();?>index.php/blog/process' method='post' name='process'>
                                               ^    ^

This should be
<form action='<?php echo base_url();?>index.php/user_log/process'      method='post' name='process'>
                                               ^        ^

Instead of blog, it should be user_log.
Also you are not echoing the error message in login page.
Add this some where in your login.php may be after your <form> tag.
<?= $msg ?>

