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/cy/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('enquiries@coeddarcy.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' => 'Enw', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), )), 'jobtitle' => array('text', array( 'label' => 'Teitl Swydd', 'filters' => array('StringTrim', 'StripTags'), )), 'company' => array('text', array( 'label' => 'Cwmni', 'filters' => array('StringTrim', 'StripTags'), )), 'address' => array('textarea', array( 'label' => 'Cyfeiriad', 'filters' => array('StringTrim', 'StripTags', array('Alnum', true)), 'class' => 'text-area', )), 'telephone' => array('text', array( 'label' => 'Rhif Ffôn', 'filters' => array('StringTrim'), )), 'email' => array('text', array( 'label' => 'e-bost', 'required' => true, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array('emailAddress'), )), 'comments' => array('textarea', array( 'label' => 'Gadewch neges os gwelwch yn dda', 'filters' => array('StringTrim', 'StripTags', array('Alnum', true)), 'class' => 'text-area', 'id' => 'message' )), 'submit' => array('submit', array( 'label' => 'Cyflwyno' , 'id' => 'registerBtn' )) ), )); $form->setAttribs(array('enctype' => 'multipart/form-data')); $form->setElementDecorators(array('ViewHelper','Errors')); $form->name->removeDecorator('Errors'); $form->email->removeDecorator('Errors'); return $form; } ?> Cofrestrwch | Coed Darcy
Register

Cofrestrwch eich diddordeb

'; print '

Mae eich ymholiad wedi ei yrru ac fe gyswlltwn yn fuan. Cliciwch yma er mwyn dychwelyd i’r dudalen gartref.

'; print '
'; } ?>

Manylion Personol

name->render($view); ?> name->getMessages(); if( !empty($errors) ) { ?>
    name->getMessages() as $key=>$value ) { print '
  • ' . $value . '
  • '; } ?>
jobtitle->render($view); ?>
company->render($view); ?>

*Mae yn dynodi maes gorfodol

address->render($view); ?>
telephone->render($view); ?>
email->render($view); ?> email->getMessages(); if( !empty($errors) ) { ?>
    email->getMessages() as $key=>$value ) { print '
  • ' . $value . '
  • '; } ?>

Sylwadau

comments->render($view); ?> submit->render($view); ?>