email()->validate('user-email'); // recaptcha validation $validator->recaptcha('6LeNWaQUAAAAAOnei_86FAp7aRZCOhNwK3e2o2x2', 'Recaptcha Error')->validate('g-recaptcha-response'); // check for errors if ($validator->hasErrors()) { $_SESSION['errors']['email-styles'] = $validator->getAllErrors(); } else { $replacements = array(); // bogart theme if (in_array('bogart', $_POST['theme'])) { $replacements[] = array( 'tpl-header-image' => 'https://www.phpformbuilder.pro/assets/images/phpformbuilder-bogart-600-160.png', 'tpl-page-background' => 'url(https://www.phpformbuilder.pro/assets/images/noisy-bogart.png) repeat #1d2326', 'tpl-content-dark-background' => '#6a6a61', 'tpl-content-light-background' => '#dddcc5', 'tpl-content-dark-text' => '#1d2326', 'tpl-content-light-text' => '#dddcc5', 'tpl-content-accent-text' => '#dddcc5', 'tpl-content-accent-background' => '#611427', 'user-name' => 'Name', 'user-first-name' => 'First name', 'user-email' => 'Email' ); } // coffee theme if (in_array('coffee', $_POST['theme'])) { $replacements[] = array( 'tpl-header-image' => 'https://www.phpformbuilder.pro/assets/images/phpformbuilder-coffee-600-160.png', 'tpl-page-background' => 'url(https://www.phpformbuilder.pro/assets/images/noisy-coffee.png) repeat #4d3e39', 'tpl-content-dark-background' => '#222222', 'tpl-content-light-background' => '#f3f0e6', 'tpl-content-dark-text' => '#222222', 'tpl-content-light-text' => '#f3f0e6', 'tpl-content-accent-text' => '#ffffff', 'tpl-content-accent-background' => '#db7447', 'user-name' => 'Name', 'user-first-name' => 'First name', 'user-email' => 'Email' ); } // honey-pot theme if (in_array('honey-pot', $_POST['theme'])) { $replacements[] = array( 'tpl-header-image' => 'https://www.phpformbuilder.pro/assets/images/phpformbuilder-honey-pot-600-160.png', 'tpl-page-background' => 'url(https://www.phpformbuilder.pro/assets/images/noisy-honey-pot.png) repeat #191919', 'tpl-content-dark-background' => '#ffd34e', 'tpl-content-light-background' => '#fffad5', 'tpl-content-dark-text' => '#444444', 'tpl-content-light-text' => '#a6721a', 'tpl-content-accent-text' => '#fffad5', 'tpl-content-accent-background' => '#bd4932', 'user-name' => 'Name', 'user-first-name' => 'First name', 'user-email' => 'Email' ); } // sandy-stone theme if (in_array('sandy-stone', $_POST['theme'])) { $replacements[] = array( 'tpl-header-image' => 'https://www.phpformbuilder.pro/assets/images/phpformbuilder-sandy-stone-600-160.png', 'tpl-page-background' => 'url(https://www.phpformbuilder.pro/assets/images/noisy-sandy-stone.png) repeat #002f2f', 'tpl-content-dark-background' => '#a7a37e', 'tpl-content-light-background' => '#f9f8e9', 'tpl-content-dark-text' => '#333333', 'tpl-content-light-text' => '#f9f8e9', 'tpl-content-accent-text' => '#f9f8e9', 'tpl-content-accent-background' => '#198181', 'user-name' => 'Name', 'user-first-name' => 'First name', 'user-email' => 'Email' ); } // vintage theme if (in_array('vintage', $_POST['theme'])) { $replacements[] = array( 'tpl-header-image' => 'https://www.phpformbuilder.pro/assets/images/phpformbuilder-vintage-600-160.png', 'tpl-page-background' => 'url(https://www.phpformbuilder.pro/assets/images/noisy-vintage.png) repeat #2f343b', 'tpl-content-dark-background' => '#703030', 'tpl-content-light-background' => '#e3cda4', 'tpl-content-dark-text' => '#2f343b', 'tpl-content-light-text' => '#e3cda4', 'tpl-content-accent-text' => '#e3cda4', 'tpl-content-accent-background' => '#e55e3d', 'user-name' => 'Name', 'user-first-name' => 'First name', 'user-email' => 'Email' ); } // zen theme if (in_array('zen', $_POST['theme'])) { $replacements[] = array( 'tpl-header-image' => 'https://www.phpformbuilder.pro/assets/images/phpformbuilder-zen-600-160.png', 'tpl-page-background' => 'url(https://www.phpformbuilder.pro/assets/images/noisy-zen.png) repeat #10222b', 'tpl-content-dark-background' => '#bdd684', 'tpl-content-light-background' => '#e2f0d6', 'tpl-content-dark-text' => '#10222b', 'tpl-content-light-text' => '#f6ffe0', 'tpl-content-accent-text' => '#f6ffe0', 'tpl-content-accent-background' => '#10222b', 'user-name' => 'Name', 'user-first-name' => 'First name', 'user-email' => 'Email' ); } $count = count($replacements); // posted template if ($_POST['template'] == 'default-styled') { $template = 'default-styled.html'; } else { $template = 'contact-styled.html'; } // send an email for each posted theme for ($i=0; $i < $count; $i++) { $email_config = array( 'sender_email' => 'contact@phpformbuilder.pro', 'sender_name' => 'Php Form Builder', 'recipient_email' => addslashes($_POST['user-email']), 'subject' => 'Contact From Php Form Builder', 'filter_values' => 'email-styles', 'template' => $template, 'values' => $_POST, 'custom_replacements' => $replacements[$i], 'debug' => true ); $sent_message = Form::sendMail($email_config); } Form::clear('email-styles'); } } /* ================================================== The Form ================================================== */ $form = new Form('email-styles', 'horizontal', 'novalidate', 'bs3'); // $form->setMode('development'); $form->startFieldset('Please fill in this form to contact us'); $form->addHtml('
All fields are required
'); $form->addInput('text', 'user-name', '', 'Name:', 'required'); $form->addInput('text', 'user-first-name', '', 'First name:', 'required'); $form->addInput('email', 'user-email', '', 'Email:', 'required'); $form->addTextarea('message', '', 'Message:', 'cols=30, rows=4, required'); $form->addOption('theme[]', 'bogart', 'bogart', '', 'title=Bogart, data-content=