Codeigniter: Not inserting data in table -
update: solved ..
for reason, data not getting inserted table. being posted form see var dump, further that, won't do. so, here 3 modules. simple test scheme: form 2 fields, press submit , should inserted. (i can in ordinary php 1 page, but, mvc frameworks nightmare in regard, write 30 times more code need in procedural.
<?php class inserting_controller extends ci_controller { public function __construct() { parent::__construct(); $this->load->model('inserting_model'); } public function index () { $this->load->view('inserting_view'); } // controller public function insert() { $data = array( 'username' => $this->input->post('username', true), 'password' => sha1($this->input->post('password', true) )); var_dump($data); // data posted exit; $this->inserting_model->insertdata($data); // should forward them model } } ?> ============== model <?php class inserting_model extends ci_model{ function __construct() { // call model constructor parent::__construct(); $this->load->database(); } public function insertdata($data) { $this->db->insert('users', $data); } } ?> ======== view <div id="inserting_form"> <?php echo form_open('index.php/inserting_controller/insert/'); ?> <ul> <li> <label>username</label> <div><?php echo form_input(array('id' => 'username', 'name' => 'username')); ?></div> </li> <li> <label>password</label> <div><?php echo form_password(array('id' => 'password', 'name' => 'password')); ?></div> </li> <li><?php echo validation_errors();?></li> <li><?php echo form_submit(array('name' =>'submit'),'insert');?> </li> </ul> <?php echo form_close(); ?> </div>
blushing :/
on writing debugging code, forgot delete exit; thus, program exited right after ....
Comments
Post a Comment