Search This Blog

Thursday, November 28, 2019

Codeigniter proses tambah pelanggan

    public function ctambahpelangganprocess() {
        $varnama    = $this->input->post('nama');
        $varkota    = $this->input->post('kota');
        $vardetail  = $this->input->post('detail');

        //semua variable diatas harus ditampung menjadi 1 object sebelum dikirim
        $varobject = array(
            'namapelanggan' => $varnama, //array item namapelanggan harus sama dgn nama kolom di tabel db
            'kotapelanggan' => $varkota,
            'detailpelanggan' => $vardetail
        );

        $processquery = $this->db->insert('tbpelanggan',$varobject) ;

        if($processquery) {
            $data['pesan'] = 'data sukses ditambahkan';
            //halaman redirect after sukses tambah
            $data['content'] = 'vdisduk/vpelanggan/vlistpelanggan';
            $this->load->view('vtemplate/template',$data);

        }
        else //jika gagal insert
        {
            $data['pesan'] = "Gagal tambah pelanggan";
            $data['content'] = 'vdisduk/vpelanggan/vform';
            $this->load->view('vtemplate/template',$data);

        }






Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





No comments:

Post a Comment