Location: PHPKode > scripts > phpMyAccess > phpmyaccess-1.5.3/phpmyaccess/PHPMyEdit.php
<?php

// basic Email sending
function send_email($to, $subject, $message, $from) {
  mail($to, $subject, $message, "From: " . $from);
}

// Debugging aid for displaying form vars
function DisplayArrayVar($arr) {
  while (list ($num, $name) = each ($arr)) {
     echo $num . " set to : " . $name . "<br> \n";
  }
}

include "pma-debuginc.php";
include "pma-setupinc.php";
include "pma-sqlinc.php";
include "pma-fieldinc.php";
include "pma-recordinc.php";
include "pma-tableinc.php";
include "pma-queryinc.php";
//$editinlinelocal = "//Desired js subfunction before text reloaded into cell here\n";
//include "pma-editinline.php";
include "xlsgen.php";

// database connection
$dbl = mysql_connect($opt['hn'],$opt['un'],$opt['pw'])
  or pma_errpage("Could not connect to MySQL");
if (!isset($opt['db'])) {
   pma_errpage("No Database defined");
}
if (!isset($opt['tb'])) {
   pma_errpage("No Table defined");
}

// is auth required ??
if ($auth >= 1) {
  $auth_level = 0;
  include 'auth.inc.php';
  if ((!$auth_level) || ($auth_level < $auth)) {
     // personalise this to your liking in pma_debuginc.php
     // don't switch on debug stuff in this routine unless you are testing
     Say_No_acces_then_die();
  }
}

// if a function Pre-Run exists it will be run. This also allows access to tables,
// as the db connection has been successfully established now. The usual place for
// this function is in your program file, as created by setup.php.
if (function_exists('Pre_Run')) {
   Pre_Run();
}

// some more $opt[] to set, that have perhaps/likely been changed by Pre_run()
// They were after all pretty much designed for it
$opt['presel'] = $presel;
$opt['preselval'] = $preselval;
$opt['preselfld'] =  $preselfld;
$opt['presel1'] = $presel1;
$opt['preselval1'] = $preselval1;
$opt['preselfld1'] =  $preselfld1;

/*
  ======================================================================
  Pass 2: display an input/edit/confirmation screen if the user has
  selected an editing button on Pass 1 through this page
  ======================================================================
*/
#set_magic_quotes_runtime(0);
ini_set('magic_quotes_runtime', 0);
if ($opt['mode'] == "table") {
  $listit = true;

  if ($_POST['add'] == 'Add' and stristr($options,'A')){
	}

  // checking mode options as given in calling program.
  if (($_POST['add'] == 'Add' and stristr($options,'A'))
     or ($_POST['change'] == 'Change' and stristr($options,'C'))
     or ($_POST['delete'] == 'Delete' and stristr($options,'D'))
     or ($_POST['zoom'] == 'Zoom' and stristr($options,'Z'))) {
     MyHeader ($header);
     debug_on();
     pma_comment ($_POST['saveadd']);

     // no table list
     $listit = false;
     //  optional input required javascript

     if (($_POST['add'] == 'Add') or ($change == 'Change')) {
        make_javascript_confirm();
        echo '<form action="'.basename($_SERVER['PHP_SELF']).'" method="post" onSubmit="return form_control(this);">'."\n";
     } else {
        echo '<form action="'.basename($_SERVER['PHP_SELF']).'" method="post">'."\n";
     }

     echo '<table border="1" cellpadding="1" cellspacing="0" summary="'.$opt['tb'].'">'."\n";

     // values to save in hidden vars across invocations
     save_form_state(1);

     if ($_POST['add'] == 'Add') {
        do_add_record_form();
     } elseif ($_POST['change'] == 'Change') {
        do_change_record_form();
     } elseif (($_POST['zoom'] == 'Zoom') or ($_POST['delete'] == 'Delete')) {
        // Zoom/delete both give a detail view of all allowed fields, without options to change
        do_zoom_delete_form();
     }

     echo "</table><br>\n";
     echo "<hr /><br>\n";
     do_form_button_display();
     echo '</form>'."\n";

   } // add / change / delete / zoom options


  /*
   * ======================================================================
   * Pass 3: process any updates generated from the confirmation screen
   * displayed during Pass 2
   * ======================================================================
   */
  pma_comment (" 3rd pass ");

  if (($_POST['saveadd']=='Save') || ($_POST['savechange']=='Save')) {
     // First get the form variables
     make_valarr_from_postvar();
  }
  if ($_POST['saveadd']=='Save') {
     // Use the above form variables
     do_save_add_save();
  }
  if ($_POST['savechange']=='Save') {
     // Use the above form variables
     do_save_change($key,$opt['rec']);
  }
  if ($_POST['savedelete']=='Delete') {
     do_record_delete($_POST['savedelete'], $key, $opt['rec']);
  }

  /*
    ======================================================================
    Pass 1 and Pass 3: display the MySQL table in a scrolling window on
    the screen / do query display.
    ======================================================================
  */
  if ($listit) {

     if ($_POST['print']=='Print') {

        MyHeader ($header);
        debug_on();
        pma_comment ("Table mode start " . $_POST['saveadd'] );
        do_display_print_table();


     } else {

        MyHeader ($header);
        debug_on();
		echo "<!-- pma-editinline start -->\n";
		$editinlinelocal = "//Desired js subfunction before text reloaded into cell here\n";
		include "pma-editinline.php";
		echo "<!-- pma-editinline end -->\n";
        pma_comment ("Table mode start " . $_POST['saveadd'] );
        do_display_table();
        // run after default display stuff
        PostruncheckAndExecute();

     }
  }

  // enable this to debug, very handy,
	//echo "<b>_POST:</b> <br>";
	//DisplayArrayVar($_POST);
  // WARNING !!! will display MySql login data
	//echo "<b>opt:</b> <br>";
	//DisplayArrayVar($opt);
	//echo "<b>fdd:</b> <br>";
	//print_r($fdd);
	//echo "<br>";

  FootercheckAndExecute();

} elseif ($opt['mode']=="query") {

   MyHeader ("Query for : " . $header);
   debug_on();
		echo "<!-- pma-editinline start -->\n";
		$editinlinelocal = "//Desired js subfunction before text reloaded into cell here\n";
		include "pma-editinline.php";
		echo "<!-- pma-editinline end -->\n";
   do_display_query();
   FootercheckAndExecute();

} elseif ($opt['mode']=="xls") {

   do_get_xls();

} else {

   MyHeader ($header);
   Echo "Unkown Mode";
   FootercheckAndExecute();

}

?>
Return current item: phpMyAccess