Skip to content

issatillie/CRSF-Token-Validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Basic CRSF Validation

You can use a token to validate requests. Use the following CRSF class like this:

$csrf = new CSRF();

if (isset($_POST['submit'])) {
    $name = htmlspecialchars($_POST['name']);
    if (!$csrf->verifyRequest()) {
        die('Invalid CSRF token');
    }

    echo "Valid CSRF token: " . $name;
}
?>

<form method="POST">
    <?= $csrf->addToken(); ?>
    <input type="text" name="name" id="">
    <button type="submit" name="submit">Submit</button>
</form>

About

Basic validation for forms to prevent CRSF attacks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages