Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gnat/simple-php-form

:memo: Easily create and validate HTML forms in PHP 8.
https://github.com/gnat/simple-php-form

form forms php php-form php8 validation

Last synced: 3 months ago
JSON representation

:memo: Easily create and validate HTML forms in PHP 8.

Awesome Lists containing this project

README

        

📝 Simple PHP Form
==================
![workflow](https://github.com/gnat/simple-php-form/actions/workflows/test.yml/badge.svg)

Automatic HTML `` with validation, messages, warnings and more!

* Form fields: `text`, `textarea`, `dropdown`, `checkbox`, `radio` and `hidden`
* Validators: `required`, `email`, `phone`, `number`, `lengthmax *`, `lengthmin *`, `sizemax *`, `sizemin *`

```php
add('name', 'text', '', ['required'], 'Name', '', 'Your name is required.');
$form->add('email', 'text', '', ['required', 'email'], 'Email', '', 'Your email is required.');

if($form->validate()) // Did the form validate successfully?
{
// Get data: $form->get('name'); ...
// Success ! Send an email or register user in a database somewhere...
$form->reset(); // Reset to default form.
}
?>





display(); ?>


```

## 🎁 Installation

This is a zero dependency library.

Just drag `SimplePHPForm.php` into your project and `require('SimplePHPForm.php');`

Optionally add the assets from `examples/css` and `examples/images` to your project.

## 👁️ Examples + Screenshot

* Basic usage: **./examples/basic.php**
* Advanced usage: **./examples/advanced.php**
* Center-aligned usage: **./examples/centered.php**

Simple PHP Form Example 1

## Keywords

Forms, User Feedback, Model View Controller, PHP 8 Compatible, PHP 8+, email, input, simple, lean.