Welcome Guest, Not a member yet? Register   Sign In
How to send post data in controller codeigniter
#1

How to send post data in controller codeigniter to web API,,, help me

this my code in my controller

$kirim = array(
               't187UserName' => $this->input->post('t187UserName'),
               't187Password' => $this->input->post('t187Password'),
               'upassword' => $this->input->post('upassword'),
               't187Email' => $this->input->post('t187Email'),
               't187NamaAwal' => $this->input->post('t187NamaAwal'),
               't187NamaAkhir' => $this->input->post('t187NamaAkhir'),
               't187JKel' => $this->input->post('t187JKel'),
               't187TelpHP' => $this->input->post('t187TelpHP'),
               't187TelpRumah' => $this->input->post('t187TelpRumah'),
               't187TanggalLahir' => $this->input->post('t187TanggalLahir'),
               't187AlamatRumah' => $this->input->post('t187AlamatRumah')

           );

           $params = json_encode($kirim);

           $ch = curl_init('http://localhost:8881/webApi/registrasiAkun');
           curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
           curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
           curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
               'Content-Type: application/json',                                                                                
               'Content-Length: ' . strlen($params))                                                                      
           );
Reply


Messages In This Thread
How to send post data in controller codeigniter - by joel26 - 01-02-2015, 03:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB