在codeigniter HMVC中获取内存分配错误

时间:2013-12-26 07:17:03

标签: php mysqli codeigniter-hmvc

描述:我在本地系统中使用PHP,MySQL数据库,CodeIgniter(HMVC)和XAMPP Server创建了包含session和mysql数据库的简单登录页面。

问题:我收到以下错误:

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.

问题:请告诉我解决方法如何解决上述错误。

查看: * 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(); ?>

控制器: * 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');
            }
        }
    }

}
?>

型号: * 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 个答案:

没有答案