-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
39 lines (29 loc) · 919 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php declare(strict_types=1);
use Palmtree\Form\Captcha\GoogleRecaptcha;
use Palmtree\Form\Captcha\HCaptcha;
use Palmtree\Form\FormBuilder;
use Palmtree\Form\Type\TextType;
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../.bootstrap.php';
$builder = new FormBuilder([
'key' => 'hcaptcha',
'html_validation' => false,
]);
$builder
->add('name', TextType::class, [
'label' => 'Please enter your name',
])
->add('hcaptcha', 'captcha', [
'captcha' => new HCaptcha('6b1ef180-ed78-4948-ae66-258e0bfe4ecc', 'ES_c1935238614149509f69db166c2f970d'),
]);
$builder->add('send_message', 'submit');
$form = $builder->getForm();
$form->handleRequest();
if ($form->isSubmitted() && $form->isValid()) {
redirect('?success=1');
}
$view = template('view.phtml', [
'form' => $form,
'success' => (!empty($_GET['success'])),
]);
echo $view;