Welcome Guest, Not a member yet? Register   Sign In
Help please!
#1

[eluser]Unknown[/eluser]
I'm new in codeigniter please help me.. I have no error when it comes to running my program but the inputs are not recognize my database basically it turns out the data that I inputted does not go to my database.

here is my controller function

Code:
public function displayClientsFormsPage(){
  
  
   if($this->_submit_validate()===FALSE){
    
  
    
    $data['title'] = 'Clients Form';
    
    
    $this->load->view('vclientsform',$data);
    return;
   }
  
   else{
  
    $data['last_name'] = $this->input->post('last_name');
    $data['first_name'] = $this->input->post('first_name');
    $data['owner_contact'] = $this->input->post('owner_contact');
    $data['owner_email'] = $this->input->post('owner_email');
    $data['owner_gender'] = $this->input->post('owner_gender');
    $data['owner_address'] = $this->input->post('owner_address');
    $data['contactperson_lastname'] = $this->input->post('contactperson_lastname');
    $data['contactperson_firstname'] = $this->input->post('contactperson_firstname');
    $data['pet_name'] = $this->input->post('pet_name');
    $data['pet_breed'] = $this->input->post('pet_breed');
    $data['pet_markings'] = $this->input->post('pet_markings');
    $data['pet_gender'] = $this->input->post('pet_gender');
    $data['pet_bdate'] = $this->input->post('pet_bdate');
    
    
  
  
  
    $this->m_user->insertClient($data);
  
  
  
  
    $this->session->set_flashdata('message','New Client Added');
  
    redirect('cform/displayClientsFormsPage');
    }  
  }

here's the model

Code:
public function insertClient($data)
  {
  if($this->db->insert('tb_pet','tb_owner',$data)){
  
    return TRUE;
   }
    return FALSE;
  
  }

I think the problem is in my condition because there is a foreign key in my tb_pet specifically owner_id.. I already load my model..


thanks in advance
#2

[eluser]roy3600[/eluser]
Are you sure that 3 "="'s are correct?

if($this->_submit_validate()===FALSE){



I think it should be the following, I'm also quite new to CodeIgniter:

if($this->_submit_validate()==FALSE){
#3

[eluser]PhilTem[/eluser]
What does your _submit_validate() method do?

Nonetheless: Your insertClient() method is wrong. It should be

Code:
function insertClient($data)
{
  if ( $this->db->insert('table_name', $data) )
  {
    return TRUE;
  }
  
  return FALSE;
}
#4

[eluser]Unknown[/eluser]
my _submit_validate is my funtion for setting the rules in my forms.. well thank you I already find the problem Smile tnx for the effort bros.. Smile




Theme © iAndrew 2016 - Forum software by © MyBB