1. Go to this page and download the library: Download zoxta/csrf 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/ */
zoxta / csrf example snippets
use Zoxta\Csrf;
# instantiate the class
$CsrfToken = new JwtCsrfToken();
# if a form is submitted (using POST)
if (! empty($_POST['_token'])) {
# check if CSRF is invalid
if ($CsrfToken->isInvalid()) {
# return an error if CSRF token is invalid/expired
echo '<h1>Invalid token, stop.</h1>';
} else {
echo '<h1>Valid token, process form.</h1>';
}
exit;
}
if ($CsrfToken->isValid()) {
# process the form request
echo '<h1>Valid token, process form.</h1>';
exit;
}
`html
<form action="" method="post">
<!-- form fields -->
<?= $CsrfToken->field()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.