getting memory allocation error in codeigniter HMVC

606 views Asked by At

Description: I created simple login page with session and mysql database using PHP,MySQL Database,CodeIgniter(HMVC) and XAMPP Server in local system.

Problem: I am getting following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes) in C:\xampp\htdocs\ci\application\third_party\MX\Modules.php on line 114.

Question: Please tell me the solution how to resolve this above error.

View: *login2.php*

<?php echo form_open(/* base_url(). */'user/user/login'); ?>
<?php
if ($this->session->flashdata('login_error')) {
    echo 'you have entered an incorrect username or password';
}
echo validation_errors();
?>
<label>UserName</label>
<div>
    <?php echo form_input(array('id' => 'username', 'name' => 'username', 'placeholder' => 'Enter ur name')); ?>
</div>
<label>Password</label>
<div>
    <?php echo form_password(array('id' => 'password', 'name' => 'password', 'placeholder' => 'Enter ur password')); ?>
</div> 
<div>
    <?php echo form_submit(array('name' => 'submit'), 'Login'); ?>
</div>
<?php echo form_close(); ?>

Controller: *user.php*

<?php

class User extends CI_Controller {

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

    function index() {
        $this->login();
    }

    function main_page() {
        echo 'You are logged in';
    }

    function login() {
        $this->form_validation->set_rules('username', 'Username', 'required|trim|max_length[50]|xss_clean');
        $this->form_validation->set_rules('password', 'Password', 'required|trim|max_length[200]|xss_clean');
        if ($this->form_validation->run() == FALSE) {
            $this->load->view('login2');
        } else {   // process their input and login the user
            extract($_POST);
            $user_id = $this->user->login($username, $password);
            if ($user_id) {
                //login failed error...
                $this->session->set_flashdata('login_error', TRUE);
                redirect('user/login');
            } else {
                //logem in
                $this->session->set_userdata(array(
                    'logged_in' => TRUE,
                    'user_id' => $user_id
                ));
                redirect('user/main_page');
            }
        }
    }

}
?>

Model: *user.php*

<?php

Class User extends CI_Model {

    function login($username, $password) {
        $this->db->select('id, username, password');
        $this->db->from('users');
        $this->db->where('username', $username);
        $this->db->where('password', MD5($password));
        $this->db->limit(1);

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

        if ($query->num_rows() == 1) {
            return $query->result();
        } else {
            return false;
        }
    }

}
?>
0

There are 0 answers