Jump to content

Problem with variables in URL for update process


Deaddancer

Recommended Posts

I am working on a team which is creating a PHP application that lists records, and each record (row) has several dates that can be updated. Each row has it's own update button, and when you hover over it, the URL that is displayed contains all the variables to pass to the update procedure. The issue is this URL is being built with the date values that are queried when the screen is initially built. Even when one of the date fields are changed, the URL still displays the original date. Hence the changed date value is not being passed to the update routine.

 

What needs to be done for PHP to know that a date field has been changed, so it can be passed in the subsequent URL to the update routine?

 

Thanks much, I'm pretty green with PHP although I have been programming for a fairly long time.

Here is the mainline of the script;

 

<?php
internal_init();
// Make all global variables available locally
foreach($GLOBALS as $arraykey=>$arrayvalue){if($arraykey[0]!='_' && $arraykey!="GLOBALS")global $$arraykey;}

// DB Connection code
require('xl_functions001.php');
// JDE Functions
require('jde_functions.php');

// db2conn options
$options = array('i5_naming' => DB2_I5_NAMING_ON, 'i5_lib' => 'CSSTGDAT', 'i5_date_fmt' => DB2_I5_FMT_USA );

global $db2conn;
$db2conn = xl_db2_connect($options);

global $PDAN8_filt, $PDPDP4_filt, $PDANCR_filt, $View_filt, $PDDOCO_filt, $PDMCU_filt, $MOD_filt;

// Global variables should be defined here
global $ww_rrn, $ww_ordby, $ww_orddir, $ww_page, $ww_nx, $ww_prevpage, $ww_nextpage, $ww_listsize, $ww_mode, 
$ww_whrclause, $ww_selstring, $ww_program_state, $season_options;

// Set maximum list size for this program
$ww_listsize = 20;

// Create random field to avoid caching
$rnd = rand(0, 99999); 

// retrieve the  last state of the list: order-by column and direction (ascend/descend). 
if(isset($_SESSION[$pf_scriptname]))
$ww_program_state = $_SESSION[$pf_scriptname];
if (isset($ww_program_state['ww_orddir']))
$ww_orddir = $ww_program_state['ww_orddir'];
if (isset($ww_program_state['ww_ordby']))
$ww_ordby = $ww_program_state['ww_ordby'];
if (isset($ww_program_state['ww_page']))
$ww_page = $ww_program_state['ww_page'];

if (isset($ww_program_state['PDAN8_filt']))
$PDAN8_filt = $ww_program_state['PDAN8_filt'];
if (isset($ww_program_state['PDPDP4_filt']))
$PDPDP4_filt = $ww_program_state['PDPDP4_filt'];
if (isset($ww_program_state['PDANCR_filt']))
$PDANCR_filt = $ww_program_state['PDANCR_filt'];
if (isset($ww_program_state['View_filt']))
$View_filt = $ww_program_state['View_filt'];
if (isset($ww_program_state['PDMCU_filt']))
$PDMCU_filt = $ww_program_state['PDMCU_filt'];
if (isset($ww_program_state['PDDOCO_filt']))
$PDDOCO_filt = $ww_program_state['PDDOCO_filt'];
if (isset($ww_program_state['MOD_filt']))
$MOD_filt = $ww_program_state['MOD_filt'];

// Retrieve the rrn (if any)
//if (isset($_REQUEST['rrn']))//
//	$ww_rrn = $_REQUEST['rrn'];

// run the specified task
switch($pf_task)
{
// Default action of display
case 'default':
display();
break;

// Record display option
case 'disp':
disprcd();
break;    

// Start the add or change process
case 'beginmanage':
beginmanage();
break;

// Complete the add or change process
case 'endmanage':
endmanage();
break;    

// Start the add or change process
case 'updaterow':
updaterow();
break;

case 'filter':
filter();
break;
}
/***********************************************************************************************
End of mainline code
**********************************************************************************************/

 

And here is the update procedure;

 

function updaterow() 
{
// Make all global variables available here
foreach($GLOBALS as $arraykey=>$arrayvalue) 
{
	if ($arraykey[0]!='_' && $arraykey != "GLOBALS")
		global $$arraykey;
}

// get values from the page 
$PDDOCO = $_REQUEST["PDDOCO"];
$PDDCTO = xl_add_quote_string($_REQUEST["PDDCTO"]);
$PDKCOO = xl_add_quote_string($_REQUEST['PDKCOO']);
$Q1URRF = xl_add_quote_string($_REQUEST["Q1URRF"]);
$Q1_FOD = $_REQUEST["Q1_FOD"];

echo "Order: $PDDOCO $PDDCTO $PDKCOO $Q1URRF" . '<br>';
echo "FOD = $Q1_FOD" . '<br>';

$sql_update = "UPDATE F554311 SET(Q1\$FOD) = ($Q1_FOD) where Q1DOCO = $PDDOCO and Q1DCTO = $PDDCTO and Q1KCOO = $PDKCOO and Q1URRF = $Q1URRF with NC";

echo $sql_update . '<br>';

// Update row in table. 
$result = db2_exec($db2conn, $sql_update);

// error handling
if (!$result) 
{
	die("<b>Error4 ". db2_stmt_error().":" . db2_stmt_errormsg()."</b>"); 
}


//Release the database resource
db2_close($db2conn);

//Redirect to display page
header("Location: $pf_scriptname?page=" . (string)$ww_page);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.