<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Controller {

	public function index()
	{

		$this->load->view('home');
		if(!empty($_POST)){
			$treename=$_POST['treename'];
			$nutrients=$_POST['nutrients'];
			$sunlight = $_POST['sunlight'];
			$water= $_POST['water'];
			$air= $_POST['air'];
			$temprature= $_POST['temprature'];
			$space= $_POST['space'];
			$humidity= $_POST['humidity'];

			$percentage=($_POST['nutrients'] + $_POST['sunlight'] + $_POST['water'] + $_POST['air'] + $_POST['temprature'] + $_POST['space'] + $_POST['humidity'] ) / 7;
			$this->load->model('Tree_Model');
			$this->Tree_Model->insertdata($treename,$nutrients,$sunlight,$water,$air,$temprature,$space,$humidity,$percentage);
		}
	}
	
}
