Return POST data in CodeIgniter model? -
i'm trying data form , send model below input data database table users.
i have controller (class login) following code:
class login extends ci_controller {
function __construct() { parent::__construct(); $this->load->model('login_model'); } public function index() { $data = array( 'gid' => $this->input->post('gid'), 'name' => $this->input->post('name'), 'pic' => $this->input->post('pic'), 'link' => $this->input->post('link') ); var_dump($data); $this->login_model->insert_entry($data); }
}
in model have following:
class login_model extends ci_model { public function __construct() { parent::__construct(); $this->load->database(); } function insert_entry($data) { $this->db->insert('users', $data); } }
the issue have @ moment don't think model getting data correctly. i've been using url:
domain.com/login?field1=john&field2=dave&field3=barry&field4=ted
if var dump seems return following instead of data:
array(4) { ["gid"]=> bool(false) ["name"]=> bool(false) ["pic"]=> bool(false) ["link"]=> bool(false) }
you have issues here:
- there minus sign (-) instead of equals sign (=) in first line of insert_entry()
- data sent via url data (use ci's form_open(); default post)
- your database fields , data in array potentially don't match up, , may sending extraneous data "submit" along it
Comments
Post a Comment