Simple HTML-PHP forms framework

Icon


Contents:

1   Overview
2   Technical notes
3   Source code
4   Screenshot



1. Overview.

This document is intended for developers and web designers.

I was asked by a few people about how to make an HTML form that could email the associated data or store it in a database. This document provides a simple FOSS (Free and Open Source) framework named prochpform that can be used for these purposes.

The framework consists of three files: an HTML file prochpform.html, a PHP script prochpform.php, and a PNG image prochpform.png.

The HTML file illustrates how a form may be set up and used to send data to the PHP script. The PHP script illustrates how data received from a form may be retrieved, displayed, mailed to a specified party, and/or stored in a MySQL database.

To download the framework or browse the code, see the following sections.

If you'd like to try a live copy, click here. The live copy displays a form. If you fill out the form and press the Send button, the form will transmit the specified values to a copy of prochpform.php that's configured simply to display the data. Nothing will be mailed in this case and no database records will be created.

Note: If you're interested and would like to comment, you can use this link to contact me.





2. Technical notes.

2.1. The mail feature can only be used on systems that have (a) a standard mail system installed and (b) a copy of PHP that has mail support enabled.

2.2. The MySQL feature can only be used on systems that have (a) a copy of MySQL installed and (b) a copy of PHP that has MySQL sup- port enabled.

2.3. If MySQL support is requested, the system administrator is responsible for creating a database. The PHP program handles the creation of the required table.

2.4. For MySQL support to work, the associated $MYSQL_ parameters must be set properly. For more information, see the parameters section.

2.5. If MySQL support is requested, and if the set of fields specified by the HTML form changes, the existing MySQL database will need to be deleted and recreated.

2.6. The HTML form may contain any reasonable number of fields. All fields may be optional or, alternatively, one or more of the fields may be designated as “required”. For more information, see the parameters section below.

2.7. If a data value begins with a left parenthesis ( it is assumed to be a prompt string that the HTML form displayed in the associated input field. In this case, the value is discarded.





3. Source code.

To browse the HTML code (prochpform.html), click here.

To browse the PHP code (prochpform.php), click here.

To download both source files (plus a required PNG image file) in a ZIP archive, click here.




4. Screenshot.

Here's a screenshot that shows the default version of the HTML file being displayed. Note: The fields included in the default version can be replaced. The main rule is that the PHP script needs to be modified accordingly.


image




Hosting provided by Zymic.

For acknowledgments related to CSS and other code used, click here.

Linked or embedded works (software, books, articles, etc.) are presented under their own licenses.

Other unique content on this page, excluding screenshots, is distributed under the following license: C.C. Attribution NonCommercial ShareAlike 3.0. In some cases, screenshots are distributed under the same license. In other cases, the associated program's license applies.

image Valid XHTML 1.0