Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Captcha field results in white page


Reply

2 Posts   1167 Views

Avatar
Mediaversa

14 June 2010 at 8:42pm Community Member, 5 Posts

Hello everyone,

I'm trying to add a ReCaptcha field to my contact page's field. However when a form is filled including the captcha, the page directs me to a blank page, and the form is not send. The code i've used for the form:

------------------

<?php
class ContactPage extends Page
{
   static $db = array(
   'Mailto' => 'Varchar(100)',
   'SubmitText' => 'HTMLText'
   );
   
   function getCMSFields() {
   $fields = parent::getCMSFields();
   
   $fields->addFieldToTab("Root.Content.OnSubmission", new TextField('Mailto', 'Email submissions to'));
   $fields->addFieldToTab("Root.Content.OnSubmission", new TextareaField('SubmitText', 'Text on Submission'));
   
   return $fields;
   }
}

class ContactPage_Controller extends Page_Controller
{
   function ContactForm()
   {
      $Params = Director::urlParams();
      // Create fields
      $fields = new FieldSet(
      new TextField('Bezoekdatum', 'Bezoekdatum *'),
      new TextField('Naam', 'Naam *'),
      new TextField('Vereniging', 'Vereniging'),
      new TextField('Adres', 'Adres / Nr *'),
      new TextField('Postcode', 'Postcode / Plaats *'),
      new TextField('Telefoon', 'Telefoon / Mobiel *'),
      new EmailField('ContactEmail', 'Email *'),
      new TextField('Aantal', 'Aantal Personen: (volwassenen en kinderen onder de 12) *'),
      new TextField('Tijdstip', 'Tijdstip *'),
      new DropdownField('Rondleiding', 'Rondleiding door de molens *',array("Ja"=> "Ja" , "Nee" => "Nee", ),''),
      new DropdownField('Wandeling', 'Wandeling met natuurgids *',array("Ja"=> "Ja" , "Nee" => "Nee"),''),
      new TextField('Drinken', 'Koffie / Thee (aantal invullen) *'),
      new TextField('Koek', 'Molenkoek (aantal invullen) *'),
      new TextareaField('Wensen','Overige wensen/vragen',4,16)
);
      
      // Create action
      $actions = new FieldSet(
      new FormAction('SendContactForm', 'Verzenden')
      );
      
      // Create Validators
      $validator = new RequiredFields('Naam', 'ContactEmail', 'Bezoekdatum', 'Adres', 'Postcode', 'Telefoon', 'Aantal', 'Tijdstip', 'Rondleiding', 'Wandeling', 'Drinken', 'Koek');
      
      //return new Form($this, 'ContactForm', $fields, $actions, $validator);
      $form = new Form($this, 'ContactForm', $fields, $actions, $validator);
      $protector = SpamProtectorManager::update_form($form, 'Comments'); // to make the recaptcha work with your form
      return $form;
   }
   
   function SendContactForm($data)
   {
      
      //Set data
      $From = $data['ContactEmail'];
      $To = $this->Mailto;
      $Subject = "Aanmelding voor rondleiding via de website";
      $email = new Email($From, $To, $Subject);
      //set template
      $email->setTemplate('TourEmail');
      //populate template
      $email->populateTemplate($data);
      //send mail
      $email->send();
      //return to submitted message
      Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
   }
   
   public function Success()
   {
      return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
   }
}

------------------

Hope somebody knows a solution for this,

thx,
Xander

Avatar
Willr

14 June 2010 at 9:31pm Forum Moderator, 5511 Posts

the page directs me to a blank page

Have you got display_errors turned on in your php.ini file (or can you look at your PHP error log for any errors).