PHP code example of davodm / codeigniter4-turnstile
1. Go to this page and download the library: Download davodm/codeigniter4-turnstile library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public $ruleSets = [
// other rules
\CI4CFTurnstile\Validation\TurnstileRules::class,
];
$validation = \Config\Services::validation();
$validation->setRules([
'turnstile_field_name' => 'ors = $validation->getErrors();
// Display errors to the user
}
namespace App\Controllers;
use CodeIgniter\Controller;
class FormController extends Controller
{
public function index()
{
helper('turnstile');
return view('form');
}
public function submit()
{
$validation = \Config\Services::validation();
$validation->setRules([
'turnstile_field_name' => '
<!-- Implicit form model -->
<form method="post" action="/form/submit">
<!-- Other form fields -->
<?= turnstile_implicit('turnstile_field_name');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.