genquery.pl: Perl SQL database interface package for html

Summary

This package has various functions for generating html code from an SQL table structure and for generating SQL statements (Select, Insert, Update, Delete) from an html form. You can build a complete forms interface to an SQL database (query, add, update, delete) without any programming! The software is available at http://www.odbsoft.com/cook/sources.htm

Functionality

Calling details

All functions are very simply called by submitting a link with the tablename in the submission parameters. The 'table' parameter is required on all forms, the 'id' parameter is required on update and delete, all other parameters are optional.

query.pl?table=tablename&fields=col1,col2,...&orderby=col1,col2...&debug=1

Produces a query form and submit button. The fields optional parameter is the fields to include on the form; the default is to include all non TEXT (i.e. long) columns. The orderby parameter orders the result set. The debug parameter displays the generated SQL statement(s).

view.pl?table=tablename&id=xxx

Produces a full-record printout with all columns.

add.pl?table=tablename&debug=1

Produces a data-entry form and submit button.

update.pl?table=tablename&id=xxx

Produces a filled in data-entry form and allows user to modify record after verifying security key.

delete.pl?table=tablename&id=xxx&debug=1

Deletes the record after verifying the security key.

Using MySQL

On Unix mysql tablenames are case sensitive, but not column names. Create your tables and columns with capitalization to maximize readability, since these are the names that will be displayed on the forms.

Testing your application

For security reasons SQL error information is not returned to the web user. Test your application from the command line by creating a data file with the names/values of submission parameters on each line ("field=value") and then issuing the command: perl query.pl <t.dat; or else enter parameters when prompted and end with ctrl-Z (ctrl-D on Unix). Remember to tell genquery.pl whether you are using a local (ODBC) data-source or a remote one, see dbOpen() function.

Author

Send feedback, appreciation, enhancements, and business propositions to marc@odbsoft.com

This software is freely modifiable and distributable, but please keep the author/contact information on the source header.