public function contactAction(array $params) { //creating form entity $form = new ContactForm($_POST); //check if we have a flash message in get params $flash_msg = isset($params['flash_msg']) ? $params['flash_msg'] : ''; //if form sent if ($_POST) { if ($form->validate()) { $flash_msg = 'Message sent'; $email_body = "This is a message from {$form->getName()}, {$form->getEmail()} : {$form->getMessage()}"; //C:\xampp\mailoutput mail('*****@*****.**', 'Contact message', $email_body); if ($_FILES['attachment']) { $form->uploadAttachment(); } } else { $flash_msg = 'Fill in the fields'; } //redirectt header("Location: /index.php?controller=index&action=contact&flash_msg={$flash_msg}"); } $data = array('form' => $form, 'message' => $flash_msg); return $this->render('contact', $data); }