PHP code example of digitaladapt / vigilant-form-kit
1. Go to this page and download the library: Download digitaladapt/vigilant-form-kit 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/ */
digitaladapt / vigilant-form-kit example snippets
use VigilantForm\Kit\VigilantFormKit;
/* once per page, setup and run the tracking */
$vigilantFormKit = new VigilantFormKit("<SERVER_URL>", "<CLIENT_ID>", "<CLIENT_SECRET>");
// optional, defaults to (new SessionBag(), "vigilantform_")
// note: for Laravel you can use $request->session().
//$vigilantFormKit->setSession($session, "<PREFIX>");
// optional, defaults to ("age", "form_sequence", "/vf-pn.js", "vf-pn")
// note: "<HONEYPOT>" and "<SEQUENCE>" must be unique form field names.
// note: "<SCRIPT_SRC>" must be a public javascript file location.
// note: "<SCRIPT_CLASS>" must be the identifier used to process the honeypot in said javascript.
$vigilantFormKit->setHoneypot("<HONEYPOT>", "<SEQUENCE>", "<SCRIPT_SRC>", "<SCRIPT_CLASS>");
// optional, defaults to (new NullLogger())
//$vigilantFormKit->setLogger($logger);
// once everything is setup, run the tracking
// if this request is a non-page (script or image) file,
// pass true to track the referral page instead.
$vigilantFormKit->trackSource();
/* once per form, add honeypot field, recommend just before submit */
echo $vigilantFormKit->generateHoneypot();
use UnexpectedValueException;
/* handle form submission */
if (!empty($_POST)) {
try {
// will determine if user failed the honeypot test, calculate duration, and submit to server.
$vigilantFormKit->submitForm("<WEBSITE>", "<FORM_TITLE>", $_POST);
} catch (UnexpectedValueException $exception) {
// handle submitForm failure
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.