gnat / simple-php-form
Automatically generate and handle input forms in PHP.
dev-master
2023-06-27 19:44 UTC
Requires
- php: ^8.0
This package is not auto-updated.
Last update: 2024-04-17 18:32:11 UTC
README
Automatic HTML <form>
with validation, messages, warnings and more!
- Form fields:
text
,textarea
,dropdown
,checkbox
,radio
andhidden
- Validators:
required
,email
,phone
,number
,lengthmax *
,lengthmin *
,sizemax *
,sizemin *
<?php require('SimplePHPForm.php'); $form = new SimplePHPForm(); $form->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. } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" media="screen" href="css/simplephpform_default.css" /> </head> <body> <?php echo $form->display(); ?> </body> </html>
🎁 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
Keywords
Forms, User Feedback, Model View Controller, PHP 8 Compatible, PHP 8+, email, input, simple, lean.