PHP Form Generator Requirements

phpMyEdit was commercially licensed for this project. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders. These trademark holders are not affiliated with this website, nor do they sponsor or endorse this website.

phpMyEdit is adequate for basic MySQL™ data management when using MyISAM type tables. Column 0 must be the unique identifier (i.e. multi-key tables are not supported). phpMyEdit's JOIN syntax can be rather challenging (if possible, use a VIEW created with phpMyAdmin).

Buyers must possess fundamental experience with MySQL™, PHP, LAMP or WAMP environment, and phpMyAdmin. This app built and tested using PHP version 5.5.12 and MySQL™ version 5.6.17.

MySQL™ version 5+ with MySQL™ Improved Connection and utf8 character set. If using a character set other than utf8, specify that character set when configuring the included database connection.

MySQL™ MyISAM tables where the first column is the unique key.

PHP version 5+ with MySQLi extensions installed.

Install the provided `change_log` schema.

phpMyEdit does not work with multiple key tables, foreign key tables, or complex INNODB tables.

No user authentication is built in, thus make your own security arrangement (such as placing this project in a password protected directory).

This app relies on a CDN (content delivery network) for the minified Bootstrap style sheet in the header, and in the footer, four minified JavaScript files. If you plan to use this app offline (e.g. without Internet connectivity in a WAMP environment) then you will need to download the remote style sheet and four JavaScript files, save them to an appropriate location, and change the HTML links in the included header and footer scripts. View the source code of this page in order to see the links to various CDN locations. CDN usage decreases download time since many users already have those files in their browser cache. In theory, as future Bootstrap versions are released, users will be able to adopt new Bootstrap versions for this app by simply changing 5 links.

Please read the Installation Instructions before purchasing this CRUD tool, an application designed to Create, Read, Update, or Delete database records.

Installation and configuration of the PHP Form Generator

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

Unzipping the archive will create a directory containing nearly 270 files.

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.
//$sn++;
//$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'] = '';
//$sn++;
//$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 — included by the phpMyEdit Examples page; 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 configured in the online demo.
$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.

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 directory and upload to your server.

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

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.
.. http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.logging.html
CREATE TABLE IF NOT EXISTS `change_log` (
  `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `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 concern. For example display of the 'help|ACP' option in Add/Change modes.

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.

The default filename convention is in the format draft.database.table.0.php. Rename the files if you modify them. Create new menu items.

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

Multiple style sheets may apply. Altering the order in which they are included in ./inc/header.php may have unexpected consequences.

Multiple JavaScript files may be in use. If you need to add JavaScript, add it to ./js/local.js.

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 index.htm index.html
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.

;date.timezone = America/Denver
display_errors = Off
display_startup_errors = Off
;error_log = /home/username/logs/phperrors.txt
log_errors = On
magic_quotes_gpc = Off
mysql.allow_persistent Off
mysqli.allow_persistent Off
register_argc_argv = Off
register_globals = Off
track_errors = On
upload_max_filesize = 64M
zlib.output_compression = 1
zlib.output_compression_level = 1
zlib.output_handler =

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 will be 1, resulting in 100% page width resulting from omission of <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.

For example, in Add mode if you really want your (otherwise 100% wide) forms left-justified instead of centered on the display, comment out or delete $omit_div_container = 0; inside /inc/pme.config.php, near lines 300 or 327

if(array_key_exists('PME_sys_operation', $_REQUEST)){

   $omit_div_container = 0; // prevent 100% page width in AVCPD modes

   switch($_REQUEST['PME_sys_operation'])
   {
      Case 'Change':        // if change is accessed from View mode
      Case 'PME_op_Apply':
      Case 'PME_op_Change': // if change is accessed from List mode
         $header_operation_label = 'Change';
         break;
      Case 'PME_op_Copy':
         $header_operation_label = 'Copy';
         break;
      Case 'Add':
         $header_operation_label = 'Add';
         break;
      Case 'PME_op_Delete':
         $header_operation_label = 'Delete';
         break;
      Case 'PME_op_View':
         $header_operation_label = 'View';
         break;
      default:
         break;
   }

}elseif(isset($_REQUEST['PME_sys_moreadd'])){

   $omit_div_container = 0; // prevent 100% page width in AVCPD modes

   $header_operation_label = 'Add';

}

Triggers and filters can be very useful.

Don't casually delete records. Instead, flag them as deleted and exclude them in List mode by using a filter.

When creating a MySQL™ table, consider adding this field: `deleted` ENUM('0','1') default '0';

Then use the included trigger file ./inc/triggers/mark_as_deleted.TDB.php to flag records as deleted instead of actually deleting them.

Following the author's preference, if your table contains a field named `deleted` then you will find the following code lines will automatically appear in your script.

Set a filter in your script, which in List mode serves to exclude records where `deleted` = '1'.
$opts['filters'] = 'PMEtable0.deleted = "0"';

Set a trigger in your script:
$opts['triggers']['delete']['before'] = './inc/triggers/mark_as_deleted.TDB.php';

Comment out the `deleted` array in the generated script. Make sure the trigger is called (typically set in the config file).

Test that this works as planned: add a test record, return to List mode, delete the record using the Delete icon, return to List mode and check that the record no longer appears in List mode, then use phpMyAdmin to access the table and confirm the test record exists in the database table.

Taking the time to configure `deleted` ENUM('0','1') default '0'; as a field, and add a trigger and add a filter can seem like a lot of work, but it isn't. Eventually a user will unintentionally delete a record. These precautions will save the data and the project administrator can un-delete the record(s).