Jump to content

Validate if data already exist in the database


  • Please log in to reply
No replies to this topic

#1 chickenstealers



  • Members
  • Pip
  • 1 posts

Posted 26 January 2017 - 07:45 AM

Hey i'm new to grocery crud,


I want to implement validation data on my add form

the form had multiple field :

company, address, city, state, country

when i type company name in the company field it will run validation to check wether the data is already in the database or not

if the data already exist then pop up the warning that the data is already exist, and if the data is not exist yet i can input the rest of the field


the code i'm trying to use to validate is

function validate()
		$value = $this->input->get('value');
		$data = $this->Company_model->get_company_by_companyname ($value);
		$result = array();
			$result['validate'] = 1;
			$result['url'] = site_url('company/edit/' . $data['id_company']);
		else $result['validate'] = 0;		
		echo json_encode($result);

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users