Assalamualaikum,.. tinggal cek ke database sebelum insert user tersebut, buka file application\controllers\Auth .php , lalu pada baris 22 tambahkan cek email ke Database , perubahan scriptnya nanti menjadi seperti ini : $cek = $thid->db->query("SELECT * FROM rb_konsumen where email='".$this->input->post('d')."'"); if ($cek->num_rows()>=1){ redirect('auth/register'); }else{ $data = array('username'=>$this->input->post('a'), 'password'=>hash("sha512", md5($this->input->post('b'))), 'nama_lengkap'=>$this->input->post('c'), 'email'=>$this->input->post('d'), 'alamat_lengkap'=>$this->input->post('e'), 'kota_id'=>$this->input->post('h'), 'kecamatan'=>$this->input->post('i'), 'no_hp'=>$this->input->post('j'), 'tanggal_daftar'=>date('Y-m-d H:i:s')); $this->model_app->insert('rb_konsumen',$data); $id = $this->db->insert_id(); $this->session->set_userdata(array('id_konsumen'=>$id, 'level'=>'konsumen')); if ($this->session->idp!=''){ $data = array('kode_transaksi'=>$this->session->idp, 'id_pembeli'=>$id, 'id_penjual'=>$this->session->reseller, 'status_pembeli'=>'konsumen', 'status_penjual'=>'reseller', 'waktu_transaksi'=>date('Y-m-d H:i:s'), 'proses'=>'0'); $this->model_app->insert('rb_penjualan',$data); $idp = $this->db->insert_id(); $keranjang = $this->model_app->view_where('rb_penjualan_temp',array('session'=>$this->session->idp)); foreach ($keranjang->result_array() as $row) { $dataa = array('id_penjualan'=>$idp, 'id_produk'=>$row['id_produk'], 'jumlah'=>$row['jumlah'], 'harga_jual'=>$row['harga_jual'], 'satuan'=>$row['satuan']); $this->model_app->insert('rb_penjualan_detail',$dataa); } $this->db->query("DELETE FROM rb_penjualan_temp where session='".$this->session->idp."'"); $this->session->unset_userdata('reseller'); $this->session->unset_userdata('idp'); $this->session->set_userdata(array('idp'=>$idp)); } redirect('members/profile'); }
|