如何在代码点火器hmvc中将数据插入数据库?

时间:2017-10-08 16:34:26

标签: php codeigniter-hmvc

我正在尝试这个代码,它似乎在没有输入数据但我需要数据来自表单时工作。页面没有反应,只在网址中添加了问号。

 //On view folder
<form method = "" action = "">
        <?php
            echo form_open('Cntrl_SignUp/add_user');
            echo form_label('Username:');
            echo form_input(array('username'=>'username'));
            echo form_submit(array('id'=>'submit','value'=>'SIGN UP'));
            echo form_close();
        ?>

    </form>
 // On controller folder
<?php    
    class Cntrl_SignUp extends MX_Controller 
    {
        function __construct()
        {
            parent::__construct();
            $this->load->helper('url');
            $this->load->database();
            $this->load->helper('form');
        }
        public function index()
        {

            $this->load->view('vw_signUp');
        }

        public function add_user()
        {
            $this->load->model('Mdl_SignUp');
            $data = array(
                            'username' => $this->input->post('username')
                        );
            $this->Mdl_SignUp->insert($data);
            $query = $this->db->get("tblUser");
            $data['records'] = $query->result();
            echo 'Sign Up Successful!';
        }
    }

    ?>

0 个答案:

没有答案