load->library('upload',$config); $this->upload->initialize($config); if ($config) { $this->load->library('form_validation'); $this->form_validation->set_rules('product_id', 'Product', 'trim|required|xss_clean'); $this->form_validation->set_rules('fullname[]', 'Name', 'trim|required|xss_clean'); $this->form_validation->set_rules('email[]', 'Email', 'trim|required|xss_clean'); if($this->input->post('status')==0) { $this->form_validation->set_rules('company[]', 'Company', 'trim|required|xss_clean'); $this->form_validation->set_rules('jobtitle[]', 'Job Title', 'trim|required|xss_clean'); $this->form_validation->set_rules('industry[]', 'Industry', 'trim|required|xss_clean'); } if ($this->form_validation->run() == FALSE) { $message=$this->v2->alert('warning',validation_errors()); $response=array('error',$message); } else { $product = $this->input->post('product'); $product_id = $this->input->post('product_id'); $salutation = $this->input->post('salutation'); $fullname = $this->input->post('fullname'); $email = $this->input->post('email'); $company = $this->input->post('company'); $jobtitle = $this->input->post('jobtitle'); $address = $this->input->post('address'); $phonenumber = $this->input->post('phonenumber'); $personal = $this->input->post('personal'); $industry = $this->input->post('industry'); $y = count($salutation); $nom=0; $nom++; for ($i = 0; $i < $y; $i++) { $postData['salutation'] = $salutation[$i]; $postData['fullname'] = $fullname[$i]; $postData['email'] = $email[$i]; $postData['company'] = $company[$i]; $postData['jobtitle'] = $jobtitle[$i]; $postData['address'] = $address[$i]; $postData['phonenumber'] = $phonenumber[$i]; $postData['personal'] = $personal[$i]; $postData['industry'] = $industry[$i]; $postData['product_name']=$product; $postData['product_id']=$product_id; $postData['password']=$this->randomKey(6); print ($i); $this->v2->inject_transaction_member($postData); } } $message=$this->v2->alert('success','Success input data'); $response=array('success',$message); // $message=json_encode($_POST); echo json_encode($response); } else { redirect('admin/Trans/detail/'); } } ?>