setEncoding('UTF-8'); $view->doctype(Zend_View_Helper_Doctype::XHTML1_TRANSITIONAL); $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); // Translation for form errors $english = array( //Form Validation Errors 'isEmpty' =>'This item is required', 'emailAddressInvalid' => 'The email address entered is invalid', 'notAlnum' => 'Only characters and numbers allowed', 'dateInvalid' => 'The date entered is invalid', 'regexNotMatch' => 'Invalid', 'notDigits' => 'Please enter numerals only', //BDG Validation Errors 'invalidPostcode' =>'Please enter a valid UK Postcode', 'invalidTelephone' =>'Please enter a valid telephone number', ); $translate = new Zend_Translate('array', $english,'en'); $translate->setLocale('en'); Zend_Registry::set('Zend_Translate', $translate); // Create form $form = enquiry_form(); $valid = FALSE; if($_POST) { if ($form->isValid($_POST)) { // send $data = $form->getValues(); /* print '
'; print_r($data); print ''; */ $subject = sprintf("Coed Darcy Registration form submitted from %s", $data['name']); $submissionTime = 'The following message submited ' . date('l jS \of F Y , m.d.y , h:i:s A'); $msg = "Coed Darcy Registration Form (From http://www.coed-darcy.co.uk/register.html)\n\n"; $msg .= $data['name'] ? 'Name: '. $data['name'] . "\n" : ''; $msg .= $data['jobtitle'] ? 'Job Title: '. $data['jobtitle'] . "\n" : ''; $msg .= $data['company'] ? 'Company: '. $data['company'] . "\n" : ''; $msg .= $data['address'] ? 'Address: '. $data['address'] . "\n\n" : ''; $msg .= $data['telephone'] ? 'Telephone: '. $data['telephone'] . "\n" : ''; $msg .= $data['email'] ? 'E-mail Address: '. $data['email'] . "\n" : ''; $msg .= $data['comments'] ? 'Comments: '. $data['comments'] . "\n\n" : ''; $msg .= $submissionTime; //Send mail $mail = new Zend_Mail('utf8'); $mail->setBodyText($msg); $mail->setFrom('registration@coeddarcy.com', 'Coed Darcy Registration Form'); $mail->addTo('DHolly@stmodwen.co.uk', 'Coed Darcy Registration'); $mail->addBcc('data.capture@bradleydyer.com', 'Coed Darcy Registration'); $mail->setSubject($subject); $n = $mail->send(); if($n){ //echo 'sent mail'; $valid = TRUE; } } else { // error! } } function enquiry_form() { $form = new Zend_Form(array( 'method' => 'post', 'action' => $_SERVER['PHP_SELF'], 'elements' => array( 'name' => array('text', array( 'label' => 'Name', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), )), 'jobtitle' => array('text', array( 'label' => 'Job Title', 'filters' => array('StringTrim', 'StripTags'), )), 'company' => array('text', array( 'label' => 'Company', 'filters' => array('StringTrim', 'StripTags'), )), 'address' => array('textarea', array( 'label' => 'Address', 'filters' => array('StringTrim', 'StripTags', array('Alnum', true)), 'class' => 'text-area', )), 'telephone' => array('text', array( 'label' => 'Telephone', 'filters' => array('StringTrim'), )), 'email' => array('text', array( 'label' => 'E-mail', 'required' => true, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array('emailAddress'), )), 'comments' => array('textarea', array( 'label' => 'Please leave a message', 'filters' => array('StringTrim', 'StripTags', array('Alnum', true)), 'class' => 'text-area', 'id' => 'message' )), 'submit' => array('submit', array( 'label' => 'Submit' , 'id' => 'registerBtn' )) ), )); $form->setAttribs(array('enctype' => 'multipart/form-data')); $form->setElementDecorators(array('ViewHelper','Errors')); $form->name->removeDecorator('Errors'); $form->email->removeDecorator('Errors'); return $form; } ?>
Your enquiry has been sent and we will get back to you shortly.
'; print 'Click here to return home.
'; print '