Installation and configuration of the PHP Form Generator

The provided files are essentially a copy of this website and include phpMyEdit, mobile friendly Bootstrap HTML5 markup, demo schema, and text files.

Mobile devices are accurately identified using the $opts['mobile'] setting in ./inc/pme.config.php. You might use that to reduce the number of included records, or suppress the display of certain fields in List mode.

Unzipping the archive creates a directory named php_form_generator with about 160 files (60 language scripts for labels, trigger examples, text file examples, etc.).

Locate and modify the portions of the following 3 files, supplying database credentials.

1.) ./generator-includes/step1.php — builds the "Select a database connection" menu on the PHP Form Generator page.

// Configure (multiple) databases beginning with $sn = 0;
$sn = 0;
$cfg['server'][$sn]['charset'] = 'utf8';
$cfg['server'][$sn]['hn'] = 'localhost'; // host
$cfg['server'][$sn]['db'] = 'test'; // database
$cfg['server'][$sn]['un'] = 'root'; // username
$cfg['server'][$sn]['pw'] = ''; // password
// Optionally configure additional database connections.
//$cfg['server'][$sn]['charset'] = 'utf8';
//$cfg['server'][$sn]['log'] = 'change_log';
//$cfg['server'][$sn]['hn'] = 'localhost';
//$cfg['server'][$sn]['db'] = '';
//$cfg['server'][$sn]['pw'] = '';
//$cfg['server'][$sn]['un'] = '';
//$cfg['server'][$sn]['charset'] = 'utf8';
//$cfg['server'][$sn]['log'] = 'change_log';
//$cfg['server'][$sn]['hn'] = 'localhost';
//$cfg['server'][$sn]['db'] = '';
//$cfg['server'][$sn]['pw'] = '';
//$cfg['server'][$sn]['un'] = '';

2.) ./generator-includes/examples-include.php — scans for files whose filename includes both the name of a configured database and draft.. This is primarily for the benefit of the online demo though it might be handy to retain while familiarizing yourself with this application.

// multiple databases are configurable.
$db0 = 'test'; // Set this one for sure
$db1 = ''; // Empty if not using a 2nd database
$db2 = ''; // Empty if not using a 3rd database

3.) ./inc/pme.config.php — phpMyEdit script configuration includes many options, most importantly the database credentials. Connection functions existing in the class file have been suppressed. Connections to multple databases can be easily configured.

switch($sn) // $sn is written to scripts individually in order to select the appropriate log-in
   Case 0: // Your first (and/or only) database connection
      $opts['hn'] = 'localhost'; // host
      $opts['db'] = 'test'; // database
      $opts['un'] = 'root'; // username
      $opts['pw'] = ''; // password
      $opts['charset'] = 'utf8'; // utf8 highly recommended
   //Case 1: // Optional 2nd database
      //$opts['hn'] = 'localhost';
      //$opts['db'] = '';
      //$opts['un'] = '';
      //$opts['pw'] = '';
      //$opts['charset'] = 'utf8';
   Case 2: // Optional 3rd database
      //$opts['hn'] = 'localhost';
      //$opts['db'] = '';
      //$opts['un'] = '';
      //$opts['pw'] = '';
      //$opts['charset'] = 'utf8';
   //Optional 4th database would be added as follows
   //Case 3:
      //$opts['hn'] = 'localhost';
      //$opts['db'] = '';
      //$opts['un'] = '';
      //$opts['pw'] = '';
      //$opts['charset'] = '';
      abort('No database credentials specified');

Optionally rename the directory php_form_generator and upload to your server.

Apply password protection to the uploaded directory. Your website control panel may offer a "Protect Directories" utility to facilitate user log in.

Use phpMyAdmin or a similar utility to install the `change_log` schema which appears below. Rarely will you need to use the change log, yet when someone inadvertently deletes a record, you will be very glad this was implemented. See logging user actions with phpMyEdit forms.

-- Table structure for table `change_log`
-- Highly recommended, especially for multi-user environments.
-- Disaster prevention.
  `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
  `user` varchar(50) NOT NULL DEFAULT '',
  `host` varchar(255) NOT NULL DEFAULT '',
  `operation` varchar(50) NOT NULL DEFAULT '',
  `tab` varchar(50) NOT NULL DEFAULT '',
  `rowkey` varchar(255) NOT NULL DEFAULT '',
  `col` varchar(255) NOT NULL DEFAULT '',
  `oldval` mediumtext,
  `newval` mediumtext,
  `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_tab` (`tab`),
  KEY `idx_col` (`col`),
  KEY `idx_operation` (`operation`),
  KEY `idx_rowkey` (`rowkey`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='See the change_log features of phpMyEdit';

Point your web browser to app-form-generator.php and select a database connection.

Make 1-2 scripts for the tables that you are most familiar with. Use the script in Add and Change modes. Determine if there is anything in particular that you do not like and then review ./generator-includes/generator.config.php to see if there are configurable options that address your preferences. For example display of the 'help|ACP' option in Add/Change modes, or the display of column comments entered directly in the database structure using phpMyAdmin. Look in the /sql/ folder for schema used in this demo. The a_test_table employs a variety of column types. If you need experimental data sets, public CSV data files can be downloaded from Denver Open Data and imported using phpMyAdmin (insert a primary key auto_increment column 0 where necessary).

Create scripts for all your tables after reviewing the above mentioned configuration file. Rename the generated scripts so that you don't inadvertently over-write them in the future after you've made modifications. Remove the draft. prefix from any scripts you intend to retain.

The default filename format is draft.database.table.0.php. Rename the files and edit them! A 1 in the filename indicates the presence of the toggle feature.

Eventually you will want to modify the navbar which appears on phpMyEdit scripts, thus edit ./inc/header.php and/or ./inc/footer.php.

Multiple style sheets were used in the past. Then Bootstrap was implemented. CSS alterations remain a work in progress. Two of the three included CSS files are unused, retained for legacy reference.

If your language is not English, references in ./inc/header.php to "en-US" will need to be changed.

Multiple JavaScript files may be in use. If you need to add JavaScript, add it to ./js/local.js. A date picker is built in. You will need to edit ./js/local.js and add the names of your date columns, see examples in ./js/local.js. Consider using as DATE column names some of the names which already exist in that file.

If you maintain an .htaccess file in the directory of this installation you may (or may not) want to consider including the following lines if they don't already exist.

DirectoryIndex app-form-generator.php
AddDefaultCharset UTF-8
Options All -Indexes
ServerSignature Off

If you maintain a php.ini file in the directory of this installation you may (or may not) want to consider including the following lines.

allow_url_fopen = On
allow_url_include = On
always_populate_raw_post_data = -1
;date.timezone = "America/Denver"
display_errors = On
log_errors = On
magic_quotes_gpc = Off
mysql.allow_persistent = Off
mysqli.allow_persistent = Off
register_argc_argv = Off
register_globals = Off
session.use_only_cookies = 1
session.use_trans_sid = 0
short_open_tag = Off
track_errors = On
upload_max_filesize = 8M

Each generated script contains something like $omit_div_container = 0; where the value of $omit_div_container defaults to 0 unless Toggle Links are selected. With toggle links, the value may be set to 1, resulting in 100% page width resulting from omission of a <div class="container">.

However in modes Add, View, Change, Copy, and Delete a 100% wide layout is probably undesirable, thus $omit_div_container is conditionally reset to 0 in the configuration file. Bootstrap ROW and COL DIVs are implemented in ACVPD modes in order to prevent the data entry from from being overly wide.

See comments in ./inc/pme.config.php. Consider making a backup copy and removing verbose comments from ./inc/pme.config.php when you understand what's going on.

Review ./inc/header.php (language setting) and ./inc/footer.php.

Various directories may include a readme.txt file or instructions.txt file or possibly an unwanted .htaccess file.

NOTE: Given cumulatively sortable column header links, if Google or other robots get hold of a public script, it will follow every conceivable sort link. For days. Or weeks. Resulting in tens of thousands of (unwanted?) hits. If this happens, consider hacking the class file A HREF tags and adding rel="nofollow". Or, maybe that's already been done ... I can't recall. Need more coffee.

No user authentication exists (i.e. place this project in a password protected directory. In cPanel, use Directory Privacy for single user access).

The phpMyEdit Cheat Sheet pretty well summarizes the original documentation. Copies of the original phpMyEdit Documentation are available on both my websites: & as well as