/** * Adds new address */ public function addAction() { $this->render('addContact'); if (isset($_POST['submit'])) { $addressbook = new AddressBook($_POST); $error = $addressbook->validate(); if ((isset($error['errorFlag']) && $error['errorFlag']) === true) { $error = implode(",<br/>", $error['errorMsg']); echo $error; } elseif ($error['errorFlag'] === false) { $where = $_SESSION["user"]; if ($addressbook->addAddress($where) === true) { echo "<script>alert('Contact added Successfully!');</script>"; $this->redirect('Contacts', 'list'); } } } }