gnat / simple-php-form
自动生成和处理 PHP 输入表单。
dev-master
2023-06-27 19:44 UTC
Requires
- php: ^8.0
This package is not auto-updated.
Last update: 2024-09-18 20:25:27 UTC
README
自动生成带验证、消息、警告等的 HTML <form>
!
- 表单字段:
text
、textarea
、dropdown
、checkbox
、radio
和hidden
- 验证器:
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>
🎁 安装
这是一个无依赖的库。
只需将 SimplePHPForm.php
拖入您的项目,并执行 require('SimplePHPForm.php');
可选地,将 examples/css
和 examples/images
中的资源添加到您的项目中。
👁️ 示例 + 截图
- 基本用法:./examples/basic.php
- 高级用法:./examples/advanced.php
- 居中对齐用法:./examples/centered.php
关键词
表单、用户反馈、模型-视图-控制器、PHP 8 兼容、PHP 8+、email、输入、简单、精简。