PHPackages                             supergnaw/form-security - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. supergnaw/form-security

ActiveLibrary

supergnaw/form-security
=======================

Class for simplifying webpage form security

v1.0.2(2y ago)014AGPL-3.0PHP

Since Mar 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/supergnaw/FormSecurity)[ Packagist](https://packagist.org/packages/supergnaw/form-security)[ RSS](/packages/supergnaw-form-security/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

FormSecurity
============

[](#formsecurity)

PHP class for simplifying webpage form security. The main purpose for the creation of this class was to help mitigate against [CSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery). The class can validate the following types of inputs:

- boolean
- numeric
    - float
    - integer
    - hexadecimal integer
    - octal integer
- network
    - ipv4
    - ipv6
    - mac address
- timestamp
    - date
    - time
    - timestamp
- string
    - alphanumeric
    - hexadecimal
    - email
    - encoded html
    - url
    - string

Token
-----

[](#token)

### Form Tokens

[](#form-tokens)

FormSecurity can generate nonce tokens to be used to verify a form can only be submitted once. To use the token, simply generate a token, add it to a hidden form input, then validate the submitted token against the one saved in the session variable.

#### Generate the token

[](#generate-the-token)

```
$exampleToken = FormSecurity::token_generate('example');
```

#### Store the generated token in a form hidden input

[](#store-the-generated-token-in-a-form-hidden-input)

```
