
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 *
<?phprequire('SimplePHPForm.php');$form =newSimplePHPForm();$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><?phpecho$form->display();?> </body></html>This is a zero dependency library.
Just dragSimplePHPForm.php into your project andrequire('SimplePHPForm.php');
Optionally add the assets fromexamples/css andexamples/images to your project.
- Basic usage:./examples/basic.php
- Advanced usage:./examples/advanced.php
- Center-aligned usage:./examples/centered.php

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