private function insert() { $this->error = false; $this->msg = false; $this->v = array('_name' => '', '_branch' => '', '_phone' => ''); if (isset($_POST['client-form']) && $_POST['client-form']) { $requires = array('_name', '_branch', '_phone'); $values = $this->sanitize_fields($_POST, $requires); if (!$values) { $this->error = 'Preencha todos os campos! '; } } if (isset($values) && $values) { $values['_register_date'] = date('Y-m-d'); $client = new Model_client(); $result = $client->insert_client($values); if (!$result) { $this->error = 'Erro ao cadastrar cliente. Tente novamente! '; $this->v = array('_name' => $values['_name'], '_branch' => $values['_branch'], '_phone' => $values['_phone']); } else { $this->clients = $client->get_clients(); if (!$this->clients) { $this->error = $client->error; } include_once 'view/view-client.php'; exit; } } if (isset($client->error)) { $this->error .= $client->error; } include_once "view/client-insert.php"; }