title: Display logfile before committing transaction. Only commit if user confirms
body: <p>When I update records in the data I want to show the user the update log BEFORE the transaction is committed and give the option to continue or roll back.</p>
  
  <p>The code that commits the updates to the database follows this format:-</p>
  
  <pre><code>&lt;?php
  include 'submitLogger.php';
  
  // Begin logging
  ini_set( "error_log", $logFile );
  ini_set( "log_errors", "On" );
  ini_set( "display_errors", "Off" );
  error_log( "Log file '" . $logFile . "' created" );
  
  // Open the database
  .
  .
  
  error_log( "Connect OK" );
  .
  .
  
  error_log( "Transaction started (autocommit OFF)\n" ); 
  .
  .
  
  error_log( "Processing " . count( $deletes ) . " item(s) marked for deletion..." ); 
  .
  .
  
  
  // commit changes
  error_log( "Committing changes..." ); 
  if ( mysqli_commit( $link ) === false ) {
    mysqli_rollback( $link );
    error_log( "Commit failed. Transaction rolled back." ); 
    $response['error'] = "Could not commit changes. Transaction rolled back.";
  } else {
    error_log( "Commit successful!" ); 
    $response['success'] = "Success!";
  }
  
  // close DB connection
  .
  .
  
  // Return result
  .
  .
  </code></pre>
  
  <p>This is the code that loads the update code above and then displays the logfile, but AFTER the transaction has been committed:-</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $(document).ready( function() {
  
  
    // send AJAX request to perform the updates and begin logging
    $.post(
      '../lib/updateMenu.php', 
      sendData,
      function( response ) {
        // was it successful?
        if ( typeof response.success === 'undefined' ) {
          // no - show alert
          if ( response.error ) {
            alert( response.error );
          }
          console.error( "Amend not successful" );
          console.error( response );
          return;
        }
  
        // delete the AmendmenuAmendselected program window to force a reload on next click
        $( "#programWindowAmendmenuAmendselected" ).remove();
      },
      "json"
    ).error(function(jqXHR, textStatus, errorThrown) {
      alert( 'Unexpected error: ' + textStatus + ' ' + errorThrown );
      console.error( 'Unexpected error during amend: ' + textStatus + ' ' + errorThrown );
      console.error(jqXHR);
    }).complete(function() {
      // once a reply is received, stop the logging
      ajaxLogtail.stopTail();      
    });
  
    // begin querying log file
    var ajaxLogtail = new AjaxLogtail( '../lib/ajaxLogtail.php?logfile=' + logFile, "programWindowAmendmenuSubmit" );  
    ajaxLogtail.startTail();
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I cannot figure out how to split this so that I can display the logfile and then, if there weren't any update errors, commit the transaction.</p>
  
  <p>Does anyone have a neat idea to help, please?</p>