Installation and configuration of the PHP Form Generator

The provided files are essentially a copy of this website and include the phpMyEdit class file which supports MySQL Improved Coneection Methods (MySQLi) wrapped in mobile friendly Bootstrap HTML5 markup. Demo schema includes the highly recommended change log schema and other resources. phpMyEdit has been around for almost 20 years. It works great for tables having a unique or primary key as the first column.

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

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

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

2.) ./generator-includes/links-to-draft-files.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.) Several configuration files impacting the phpMyEdit scripts are furnished. If you only deal with one database per installation, use inx/pme.config.cvs.php which lets phpMyEdit open and close the database connection. If you need enable multiple databases and/or you need the database connection opened prior to running the phpMyEdit script, see ./inc/pme.config.0.php or ./inc/pme.config.1.php. Simply set the database credentials and run a phpMyEdit script.

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
      break;
   //Case 1: // Optional 2nd database
      //$opts['hn'] = 'localhost';
      //$opts['db'] = '';
      //$opts['un'] = '';
      //$opts['pw'] = '';
      //$opts['charset'] = 'utf8';
      //break;
   Case 2: // Optional 3rd database
      //$opts['hn'] = 'localhost';
      //$opts['db'] = '';
      //$opts['un'] = '';
      //$opts['pw'] = '';
      //$opts['charset'] = 'utf8';
      //break;
   //Optional 4th database would be added as follows
   //Case 3:
      //$opts['hn'] = 'localhost';
      //$opts['db'] = '';
      //$opts['un'] = '';
      //$opts['pw'] = '';
      //$opts['charset'] = '';
      break;
   default:
      abort('No database credentials specified');
      break;
}

Optionally rename the working directory and upload files 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 `app_change_log`
-- Highly recommended, especially for multi-user environments.
-- Disaster prevention.
.. http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.logging.html
# DROP TABLE IF EXISTS `app_change_log`;
CREATE TABLE IF NOT EXISTS `app_change_log` (
  `id` mediumint(6) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto_increment record id field',
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Current timestamp',
  `user` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'User Name if known.',
  `host` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Usually the user''s IP address. On a Windows development environment it may be ::1.',
  `operation` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Type of operation: delete, insert, update, etc.',
  `tab` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'The name of the affected table.',
  `rowkey` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'The record ID in the affected table.',
  `col` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'The name of the affected column.',
  `oldval` mediumtext COLLATE utf8_unicode_ci NOT NULL COMMENT 'The original value of the column.',
  `newval` mediumtext COLLATE utf8_unicode_ci NOT NULL COMMENT 'The new value of the column.',
  `deleted` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'A flag to suppress record display',
  PRIMARY KEY (`id`),
  KEY `idx_user` (`user`) USING BTREE,
  KEY `idx_col` (`col`) USING BTREE,
  KEY `idx_tab` (`tab`) USING BTREE,
  KEY `idx_operation` (`operation`) USING BTREE,
  KEY `idx_deleted` (`deleted`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='See the change log features of phpMyEdit. Schema modified by hockinson@gmail.com.';

Point your web browser to app-create.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/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.

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-create.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 the configurataion file. Consider making a backup copy and removing verbose comments from the configurataion file when you understand what's going on.

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

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

Copies of the original phpMyEdit Documentation are available at platon.org. The phpMyEdit Cheat Sheet pretty well summarizes the original documentation.

Grasshopper

Doug Hockinson <hockinson@gmail.com>

Voicemail: 720 two five four 7850

phpvs.com

 web hosting includes an SSL certificate, cPanel control panel, and excellent customer support